Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
product-uniqer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
product-uniqer
Commits
9b757288
There was an error fetching the commit references. Please try again later.
Commit
9b757288
authored
3 years ago
by
Bensong Liu
Browse files
Options
Downloads
Patches
Plain Diff
sync
parent
ab8ff167
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
summerize-part-list/tool_search_part_user_autoopen.py
+68
-0
68 additions, 0 deletions
summerize-part-list/tool_search_part_user_autoopen.py
with
68 additions
and
0 deletions
summerize-part-list/tool_search_part_user_autoopen.py
0 → 100644
+
68
−
0
View file @
9b757288
#!/usr/bin/python3
# A script to deal with product sheet. (see test-*.xlsx)
# Workaround for fucking Windows NT
import
traceback
def
show_exception_and_exit
(
exc_type
,
exc_value
,
tb
):
traceback
.
print_exception
(
exc_type
,
exc_value
,
tb
)
input
(
"
Press any key to exit.
"
)
sys
.
exit
(
-
1
)
import
sys
import
os
,
shutil
if
os
.
name
==
'
nt
'
:
sys
.
excepthook
=
show_exception_and_exit
# Allow import parent
import
os
,
sys
,
inspect
currentdir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
inspect
.
getfile
(
inspect
.
currentframe
())))
parentdir
=
os
.
path
.
dirname
(
currentdir
)
sys
.
path
.
insert
(
0
,
parentdir
)
################################### BEGIN #####################################
import
config
,
xlsx_conv
,
utils
def
main
():
def
contains_id
(
fname
,
_id
):
try
:
s
=
xlsx_conv
.
read_as_csv
(
fname
)
s
=
s
.
replace
(
'
'
,
''
).
replace
(
'
,
'
,
''
)
return
s
.
lower
().
find
(
_id
.
lower
())
!=
-
1
except
:
# Catch PermissionError etc.
return
False
def
got_result
(
filepath
):
print
(
"
DEBUG: HIT
"
,
filepath
)
import
subprocess
,
os
,
platform
,
time
if
platform
.
system
()
==
'
Darwin
'
:
# macOS
subprocess
.
call
((
'
open
'
,
filepath
))
elif
platform
.
system
()
==
'
Windows
'
:
# Windows
os
.
startfile
(
filepath
)
else
:
# linux variants
subprocess
.
call
((
'
xdg-open
'
,
filepath
))
exit
(
0
)
if
len
(
sys
.
argv
)
==
1
:
raise
RuntimeError
(
'
Usage: drag a file into me...
'
)
target_filename
=
os
.
path
.
basename
(
sys
.
argv
[
1
])
target_id
=
utils
.
get_id_prefix_from_string
(
target_filename
)
results
=
[]
print
(
'
Iterating... Please wait... (searching for
'
,
target_id
)
is_xlsx
=
lambda
fname
:
fname
.
endswith
(
'
.xlsm
'
)
or
fname
.
endswith
(
'
.xlsx
'
)
or
fname
.
endswith
(
'
.xls
'
)
or
fname
.
endswith
(
'
.XLSM
'
)
or
fname
.
endswith
(
'
.XLSX
'
)
or
fname
.
endswith
(
'
.XLS
'
)
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
config
.
library_path
):
for
fname
in
filenames
:
if
is_xlsx
(
fname
):
if
contains_id
(
dirpath
+
os
.
path
.
sep
+
fname
,
target_id
):
results
.
append
(
fname
)
got_result
(
dirpath
+
os
.
path
.
sep
+
fname
)
# if config.search_only_top_level_directory:
# break
if
config
.
working_dir
!=
""
:
os
.
chdir
(
config
.
working_dir
)
print
(
"
找不到存在此引用的文件
"
)
import
time
time
.
sleep
(
1000
)
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment