import base64
import xml.etree.ElementTree as XMLElementTree
+from datetime import datetime
from distutils.version import LooseVersion
from queue import Queue
from zipfile import ZipFile
if len(t) == 2:
self.apks[t[0]] = (t[1], None)
else:
- self.apks[t[0]] = (t[1], time.strptime(t[2], '%Y-%m-%d'))
+ self.apks[t[0]] = (t[1], datetime.strptime(t[2], '%Y-%m-%d'))
self.changed = False
def writeifchanged(self):
appid, added = app
line = apk + ' ' + appid
if added:
- line += ' ' + time.strftime('%Y-%m-%d', added)
+ line += ' ' + added.strftime('%Y-%m-%d')
lst.append(line)
with open(self.path, 'w', encoding='utf8') as f:
for line in sorted(lst, key=natural_key):
f.write(line + '\n')
- # Record an apk (if it's new, otherwise does nothing)
- # Returns the date it was added.
def recordapk(self, apk, app, default_date=None):
+ '''
+ Record an apk (if it's new, otherwise does nothing)
+ Returns the date it was added as a datetime instance
+ '''
if apk not in self.apks:
if default_date is None:
- default_date = time.gmtime(time.time())
+ default_date = datetime.utcnow()
self.apks[apk] = (app, default_date)
self.changed = True
_, added = self.apks[apk]
from datetime import datetime, timedelta
from xml.dom.minidom import Document
from argparse import ArgumentParser
-import time
import collections
from pyasn1.error import PyAsn1Error
wikidata += '{{App|id=%s|name=%s|added=%s|lastupdated=%s|source=%s|tracker=%s|web=%s|changelog=%s|donate=%s|flattr=%s|bitcoin=%s|litecoin=%s|license=%s|root=%s|author=%s|email=%s}}\n' % (
appid,
app.Name,
- time.strftime('%Y-%m-%d', app.added) if app.added else '',
- time.strftime('%Y-%m-%d', app.lastUpdated) if app.lastUpdated else '',
+ app.added.strftime('%Y-%m-%d') if app.added else '',
+ app.lastUpdated.strftime('%Y-%m-%d') if app.lastUpdated else '',
app.SourceCode,
app.IssueTracker,
app.WebSite,
usecache = False
if name in apkcache:
repo_file = apkcache[name]
+ # added time is cached as tuple but used here as datetime instance
+ if 'added' in repo_file:
+ a = repo_file['added']
+ if isinstance(a, datetime):
+ repo_file['added'] = a
+ else:
+ repo_file['added'] = datetime(*a[:6])
if repo_file['sha256'] == shasum:
logging.debug("Reading " + name + " from cache")
usecache = True
os.path.join(get_icon_dir(repodir, '0'), iconfilename))
if use_date_from_apk and manifest.date_time[1] != 0:
- default_date_param = datetime(*manifest.date_time).utctimetuple()
+ default_date_param = datetime(*manifest.date_time)
else:
default_date_param = None
addElement('id', app.id, doc, apel)
if app.added:
- addElement('added', time.strftime('%Y-%m-%d', app.added), doc, apel)
+ addElement('added', app.added.strftime('%Y-%m-%d'), doc, apel)
if app.lastUpdated:
- addElement('lastupdated', time.strftime('%Y-%m-%d', app.lastUpdated), doc, apel)
+ addElement('lastupdated', app.lastUpdated.strftime('%Y-%m-%d'), doc, apel)
addElement('name', app.Name, doc, apel)
addElement('summary', app.Summary, doc, apel)
if app.icon:
addElementIfInApk('obbPatchFileSha256', apk,
'obbPatchFileSha256', doc, apkel)
if 'added' in apk:
- addElement('added', time.strftime('%Y-%m-%d', apk['added']), doc, apkel)
+ addElement('added', apk['added'].strftime('%Y-%m-%d'), doc, apkel)
if file_extension == 'apk': # sig is required for APKs, but only APKs
addElement('sig', apk['sig'], doc, apkel)