Skip to content

Commit

Permalink
Merge pull request #8 from MangriMen/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
MangriMen authored Aug 10, 2021
2 parents 4dda4f9 + 8a5ce6c commit a23c8a6
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 107 deletions.
Binary file modified data/icon.ico
Binary file not shown.
Binary file added data/qtbase_ru.qm
Binary file not shown.
4 changes: 2 additions & 2 deletions libs/qt_extends.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def __init__(self):
def __fillFromJson(self, row, json_):
if json_ is None:
return
elif isinstance(json_, dict):

if isinstance(json_, dict):
for key, val in sorted(json_.items()):
newItem = StandardItem(key)
row.appendRow(newItem)
Expand Down Expand Up @@ -163,4 +164,3 @@ def showDetailedError(title, text, detailedText):
detailedMessage.setDetailedText(detailedText)
detailedMessage.setDefaultButton(QMessageBox.Ok)
detailedMessage.show()

5 changes: 2 additions & 3 deletions libs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@ def date_to_str(isoDate, format_str):
if isoDate == 'unknown':
return 'неизвестно'

out = ''
try:
out = datetime.datetime.fromisoformat(isoDate).strftime(format_str)
except ValueError:
isoDate = datetime.datetime.now().isoformat()
out = date_to_str(isoDate, format_str)
finally:
return out

return out


def thread_print(caller):
Expand Down
41 changes: 21 additions & 20 deletions libs/wiki_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def showError():

downloadTime = time.perf_counter()
if dict_['type'] == weapons or dict_['type'] == mods:
min_f = 0
min_s = 0
minF = 0
minS = 0

if dict_['type'] == weapons:
maxF = 9 # 9
Expand All @@ -51,6 +51,9 @@ def showError():
else:
return

maxF = int(maxF)
maxS = int(maxS)

try:
html = requests.get(queryPage)
html.raise_for_status()
Expand All @@ -61,39 +64,33 @@ def showError():
soup = BeautifulSoup(html.text, 'lxml')
headers_ = soup.find('div', class_=mainBlockClass).findAll('h3')

header_counter = 0
for header_ in headers_:
del headers_[:minF]
del headers_[(maxF - minF):]

for header_counter, header_ in enumerate(headers_, start=1):
if not worker_.isRunning:
return None

if header_counter < min_f:
continue
elif header_counter >= maxF:
break
header_counter += 1

header = header_.findAll('span')[1].text.strip()
if worker_.isRunning:
worker_.display_text.emit(header)
worker_.global_progress.emit(int(math.ceil(header_counter / len(headers_) * 100)))

globalProgressPercent = int(math.ceil((header_counter - 1) / len(headers_) * 100))
globalProgressNextPercent = int(math.ceil(header_counter / len(headers_) * 100))

table_ = header_.find_next_sibling()
if table_.name == 'h4':
table_ = header_.find_next_sibling().find_next_sibling().tbody.findAll('tr')
else:
table_ = table_.tbody.findAll('tr')

inner_counter = 0
for tr_ in table_:
del table_[:minS]
del table_[(maxS-minS):]

for tr_counter, tr_ in enumerate(table_):
if not worker_.isRunning:
return None

if inner_counter < min_s:
continue
elif inner_counter >= maxS:
break
inner_counter += 1

td_ = tr_.find('td')
if td_ is None:
continue
Expand Down Expand Up @@ -122,7 +119,11 @@ def showError():

if worker_.isRunning:
worker_.display_text.emit(firstLevelFormatStr % ('', a_.get('title')))
worker_.local_progress.emit(int(math.ceil(inner_counter / len(table_) * 100)))

localProgressPercent = int(math.ceil(tr_counter / len(table_) * 100))
worker_.local_progress.emit(localProgressPercent)
worker_.global_progress.emit(globalProgressPercent + (
(globalProgressNextPercent - globalProgressPercent) * (localProgressPercent / 100)))

modsTables = modsTitle.findParent().find_next_sibling().findChild()

Expand Down
Loading

0 comments on commit a23c8a6

Please sign in to comment.