Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
l0o0 authored Nov 25, 2023
1 parent 3689aae commit a55921a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@
mapDict = json.load(handle)

def read_metadata(filename):
with open(filename, encoding='utf-8') as handle:
headers = [next(handle) for x in range(13)]
return json.loads(''.join(headers))
try:
with open(filename, encoding='utf-8') as handle:
headers = [next(handle) for x in range(13)]
return json.loads(''.join(headers))
except json.decoder.JSONDecodeError:
print("Parsing Error: " + filename)
return ""

translators = os.listdir(".")
translators = [t for t in translators if t.endswith('js') and t not in ['RefWorks Tagged.js', 'BibTeX.js']]
translators = sorted(translators)

translator_metadata = {}
for t in translators:
print(t)
metadata = read_metadata("./" + t)
translator_metadata[t] = {
'label': mapDict.get(metadata['label'], metadata['label']),
'lastUpdated': metadata['lastUpdated']
}
if metadata:
translator_metadata[t] = {
'label': mapDict.get(metadata['label'], metadata['label']),
'lastUpdated': metadata['lastUpdated']
}

with open("data/translators.json", 'w', encoding='utf-8') as handle:
print(translator_metadata)
Expand Down

3 comments on commit a55921a

@jiaojiaodubai
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@l0o0 抱歉,是那个勤云科技的JS在上次更新过程中弄丢了JS文件的header,原来的header如下:

{
	"translatorID": "d611008a-850d-4860-b607-54e1ecbcc592",
	"label": "E-Tiller",
	"creator": "jiaojiaodubai23",
	"target": "^https?://.*(/ch/)?.*(.aspx)?",
	"minVersion": "5.0",
	"maxVersion": "",
	"priority": 100,
	"inRepository": true,
	"translatorType": 4,
	"browserSupport": "gcsibv",
	"lastUpdated": "2023-10-21 10:04:15"
}

@jiaojiaodubai
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接从Scaffold复制粘贴到VSCode造成的问题:(

@l0o0
Copy link
Owner Author

@l0o0 l0o0 commented on a55921a Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的同学,我更新一下

Please sign in to comment.