blind fix import compatibility
This commit is contained in:
parent
f5836b5437
commit
b481635203
2 changed files with 10 additions and 6 deletions
|
@ -153,7 +153,7 @@ class DoubanImporter:
|
|||
return None
|
||||
v = self.entity_lookup[k]
|
||||
if len(v) > 1:
|
||||
v.sort(key=lambda c: abs(timestamp - datetime.strptime(c[1], "%Y-%m-%d %H:%M:%S").replace(tzinfo=tz_sh)))
|
||||
v.sort(key=lambda c: abs(timestamp - (datetime.strptime(c[1], "%Y-%m-%d %H:%M:%S") if type(c[1])==str else c[1]).replace(tzinfo=tz_sh)))
|
||||
return v[0][0]
|
||||
# for sheet in self.mark_data.values():
|
||||
# for cells in sheet:
|
||||
|
@ -190,7 +190,9 @@ class DoubanImporter:
|
|||
content = cells[6]
|
||||
self.processed += 1
|
||||
if time:
|
||||
time = datetime.strptime(time, "%Y-%m-%d %H:%M:%S").replace(tzinfo=tz_sh)
|
||||
if type(time) == str:
|
||||
time = datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
|
||||
time = time.replace(tzinfo=tz_sh)
|
||||
else:
|
||||
time = None
|
||||
if not content:
|
||||
|
|
10
sync/jobs.py
10
sync/jobs.py
|
@ -117,6 +117,7 @@ class DoufenParser:
|
|||
start_row_index = self.__progress_row
|
||||
|
||||
# parse data
|
||||
tz = pytz.timezone('Asia/Shanghai')
|
||||
i = start_row_index
|
||||
for row in ws.iter_rows(min_row=start_row_index, max_row=max_row, values_only=True):
|
||||
cells = [cell for cell in row]
|
||||
|
@ -124,9 +125,10 @@ class DoufenParser:
|
|||
tags = cells[self.TAG_INDEX - 1]
|
||||
tags = list(set(tags.lower().split(','))) if tags else None
|
||||
time = cells[self.TIME_INDEX - 1]
|
||||
if time:
|
||||
if time and type(time) == str:
|
||||
time = datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
|
||||
tz = pytz.timezone('Asia/Shanghai')
|
||||
time = time.replace(tzinfo=tz)
|
||||
elif time and type(time) == datetime:
|
||||
time = time.replace(tzinfo=tz)
|
||||
else:
|
||||
time = None
|
||||
|
@ -150,8 +152,8 @@ class DoufenParser:
|
|||
is_first_sheet = False
|
||||
|
||||
def __get_item_number(self):
|
||||
assert not self.__wb is None, 'workbook not found'
|
||||
assert not self.__mappings is None, 'mappings not found'
|
||||
assert self.__wb is not None, 'workbook not found'
|
||||
assert self.__mappings is not None, 'mappings not found'
|
||||
|
||||
sheets = [mapping['sheet'] for mapping in self.__mappings]
|
||||
item_number = 0
|
||||
|
|
Loading…
Add table
Reference in a new issue