Compare commits
No commits in common. "141f973d8cc902335ead55823d0a590821fa4a4d" and "bab1c3859af3d30e02a01e76f8a3b8007456421e" have entirely different histories.
141f973d8c
...
bab1c3859a
4 changed files with 13 additions and 55 deletions
|
|
@ -73,8 +73,6 @@ for doc in titles:
|
||||||
|
|
||||||
('[^\d]([^, (-]+? \d+, \d{4})', '%B %d, %Y', '%Y-%m-%d'),
|
('[^\d]([^, (-]+? \d+, \d{4})', '%B %d, %Y', '%Y-%m-%d'),
|
||||||
|
|
||||||
('([^\d]{3} \d+ \d{4})', '%b %d %Y', '%Y-%m-%d'),
|
|
||||||
|
|
||||||
('[^\d]([^,]{3}, \d{4})', '%b, %Y', '%Y-%m'),
|
('[^\d]([^,]{3}, \d{4})', '%b, %Y', '%Y-%m'),
|
||||||
('[^\d]([^,]+?, \d{4})', '%B, %Y', '%Y-%m'),
|
('[^\d]([^,]+?, \d{4})', '%B, %Y', '%Y-%m'),
|
||||||
('[^\d]([^ (]+?, \d{4})', '%B, %Y', '%Y-%m'),
|
('[^\d]([^ (]+?, \d{4})', '%B, %Y', '%Y-%m'),
|
||||||
|
|
|
||||||
|
|
@ -17,31 +17,26 @@ else:
|
||||||
conditions = []
|
conditions = []
|
||||||
|
|
||||||
for regex, fragments in (
|
for regex, fragments in (
|
||||||
['Vol. (\d+), No. (\d+)', ['Vol.', 'No.']],
|
['Vol. \d+, No. \d+', ['Vol.', 'No.']],
|
||||||
['Vol (\d+) no (\d+)', [' Vol ', ' no ']],
|
['Vol \d+ no \d+', [' Vol ', ' no ']],
|
||||||
['Vol:(\d+) #(\d+)', ['Vol:', '#']],
|
['Vol:\d+ #\d+', ['Vol:', '#']],
|
||||||
#['no (\d+) (\d+)-', [' no ']],
|
|
||||||
):
|
):
|
||||||
query = {
|
|
||||||
'conditions': [
|
|
||||||
{'key': 'title', 'operator': '=', 'value': fragment}
|
|
||||||
for fragment in fragments
|
|
||||||
] + conditions,
|
|
||||||
'operator': '&'
|
|
||||||
}
|
|
||||||
for doc in api.findDocuments({
|
for doc in api.findDocuments({
|
||||||
'query': query,
|
'query': {
|
||||||
'keys': ['id', 'title', 'volume', 'issue'],
|
'conditions': [
|
||||||
|
{'key': 'title', 'operator': '=', 'value': fragment}
|
||||||
|
for fragment in fragments
|
||||||
|
] + conditions,
|
||||||
|
'operator': '&'
|
||||||
|
},
|
||||||
|
'keys': ['id', 'title', 'volume'],
|
||||||
'range': [0, 10000]
|
'range': [0, 10000]
|
||||||
})['data']['items']:
|
})['data']['items']:
|
||||||
if not doc.get('volume', ''):
|
if 'Vol' not in doc.get('volume', ''):
|
||||||
m = re.compile(regex).findall(doc['title'])
|
m = re.compile(regex).findall(doc['title'])
|
||||||
if m:
|
if m:
|
||||||
print(m[0], doc['id'], doc['title'])
|
print(m[0], doc['id'], doc['title'])
|
||||||
volume = m[0][0]
|
|
||||||
issue = m[0][1]
|
|
||||||
api.editDocument({
|
api.editDocument({
|
||||||
'id': doc['id'],
|
'id': doc['id'],
|
||||||
'volume': volume,
|
'volume': m[0].strip()
|
||||||
'issue': issue,
|
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
#!/usr/bin/python3
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import ox
|
|
||||||
import ox.api
|
|
||||||
|
|
||||||
site = 'archive.leftove.rs'
|
|
||||||
api = ox.api.signin('https://%s/api/' % site)
|
|
||||||
|
|
||||||
|
|
||||||
collection = sys.argv[1]
|
|
||||||
search = sys.argv[2]
|
|
||||||
replace = sys.argv[3]
|
|
||||||
|
|
||||||
for doc in api.findDocuments({
|
|
||||||
'query': {
|
|
||||||
'conditions': [
|
|
||||||
{'key': 'collection', 'operator': '=', 'value': collection}
|
|
||||||
],
|
|
||||||
'operator': '&'
|
|
||||||
},
|
|
||||||
'keys': ['id', 'title'],
|
|
||||||
'range': [0, 10000]
|
|
||||||
})['data']['items']:
|
|
||||||
title = doc['title'].replace(search, replace)
|
|
||||||
if title != doc['title']:
|
|
||||||
print(doc['id'], doc['title'])
|
|
||||||
print('\t->', title)
|
|
||||||
api.editDocument({
|
|
||||||
'id': doc['id'],
|
|
||||||
'title': title
|
|
||||||
})
|
|
||||||
|
|
@ -282,7 +282,6 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"columnWidth": 128,
|
"columnWidth": 128,
|
||||||
"find": true,
|
"find": true,
|
||||||
"additionalSort": [{"key": "volume", "operator": "-"}, {"key": "issue", "operator": "-"}],
|
|
||||||
"sort": true
|
"sort": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -291,7 +290,6 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"columnWidth": 128,
|
"columnWidth": 128,
|
||||||
"find": true,
|
"find": true,
|
||||||
"additionalSort": [{"key": "issue", "operator": "-"}],
|
|
||||||
"sort": true
|
"sort": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue