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
3b63731e
There was an error fetching the commit references. Please try again later.
Commit
3b63731e
authored
5 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
add a tool
parent
e88cee25
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
summerize-part-list/tool_search_part_user.py
+52
-0
52 additions, 0 deletions
summerize-part-list/tool_search_part_user.py
with
52 additions
and
0 deletions
summerize-part-list/tool_search_part_user.py
0 → 100644
+
52
−
0
View file @
3b63731e
#!/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
):
s
=
xlsx_conv
.
read_as_csv
(
fname
)
s
=
s
.
replace
(
'
'
,
''
).
replace
(
'
,
'
,
''
)
return
s
.
find
(
_id
)
!=
-
1
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...
'
)
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
)
# if config.search_only_top_level_directory:
# break
if
config
.
working_dir
!=
""
:
os
.
chdir
(
config
.
working_dir
)
print
(
results
)
with
open
(
target_id
+
'
被引用处.csv
'
,
'
w+
'
)
as
f
:
f
.
write
(
'
,
\n
'
.
join
(
results
))
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