yeref 0.24.95__tar.gz → 0.24.96__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {yeref-0.24.95 → yeref-0.24.96}/PKG-INFO +1 -1
- {yeref-0.24.95 → yeref-0.24.96}/setup.py +1 -1
- {yeref-0.24.95 → yeref-0.24.96}/yeref/yeref.py +58 -18
- {yeref-0.24.95 → yeref-0.24.96}/yeref.egg-info/PKG-INFO +1 -1
- {yeref-0.24.95 → yeref-0.24.96}/pyproject.toml +0 -0
- {yeref-0.24.95 → yeref-0.24.96}/setup.cfg +0 -0
- {yeref-0.24.95 → yeref-0.24.96}/yeref/__init__.py +0 -0
- {yeref-0.24.95 → yeref-0.24.96}/yeref/l_.py +0 -0
- {yeref-0.24.95 → yeref-0.24.96}/yeref/tonweb.js +0 -0
- {yeref-0.24.95 → yeref-0.24.96}/yeref.egg-info/SOURCES.txt +0 -0
- {yeref-0.24.95 → yeref-0.24.96}/yeref.egg-info/dependency_links.txt +0 -0
- {yeref-0.24.95 → yeref-0.24.96}/yeref.egg-info/top_level.txt +0 -0
@@ -16011,30 +16011,70 @@ async def calc_metrics(bot, PROJECT_USERNAME, dataroom_folder_id, EXTRA_D, BASE_
|
|
16011
16011
|
r4 = await return_retention_metrics(bot, data_users, EXTRA_D)
|
16012
16012
|
r5 = await return_profit_and_loss_metrics(bot, data_users, EXTRA_D)
|
16013
16013
|
|
16014
|
-
# === НОВЫЙ БЛОК: читаем CSV (r1) и заливаем его в Google
|
16014
|
+
# === НОВЫЙ БЛОК: читаем CSV (r1) и заливаем его в Google‐таблицу ===
|
16015
16015
|
if r1 and os.path.isfile(r1):
|
16016
|
-
# 1)
|
16016
|
+
# 1) Авторизация в Google Sheets через Service Account
|
16017
|
+
scopes = r_conf('scopes', CONF_P)
|
16018
|
+
credential_path = os.path.join(EXTRA_D, (r_conf('credential_file', CONF_P))[0])
|
16019
|
+
credentials = ServiceAccountCredentials.from_json_keyfile_name(credential_path, scopes)
|
16020
|
+
http_auth = credentials.authorize(httplib2.Http())
|
16021
|
+
sheets_service = build('sheets', 'v4', http=http_auth, cache_discovery=False)
|
16022
|
+
|
16023
|
+
# 2) Получаем metadata таблицы, чтобы найти sheetId для «Лист1» (или «Sheet1»)
|
16024
|
+
spreadsheet = sheets_service.spreadsheets().get(spreadsheetId=dataroom_folder_id).execute()
|
16025
|
+
sheet_id_to_rename = None
|
16026
|
+
for sheet in spreadsheet.get('sheets', []):
|
16027
|
+
props = sheet.get('properties', {})
|
16028
|
+
title = props.get('title', '')
|
16029
|
+
# если лист называется «Лист1» (русский по умолчанию) или «Sheet1» (английский)
|
16030
|
+
if title in ['Лист1', 'Sheet1']:
|
16031
|
+
sheet_id_to_rename = props.get('sheetId')
|
16032
|
+
break
|
16033
|
+
|
16034
|
+
# 3) Переименовываем лист в PROJECT_USERNAME, если нашли нужный sheetId
|
16035
|
+
if sheet_id_to_rename is not None:
|
16036
|
+
rename_request = {
|
16037
|
+
'requests': [
|
16038
|
+
{
|
16039
|
+
'updateSheetProperties': {
|
16040
|
+
'properties': {
|
16041
|
+
'sheetId': sheet_id_to_rename,
|
16042
|
+
'title': PROJECT_USERNAME
|
16043
|
+
},
|
16044
|
+
'fields': 'title'
|
16045
|
+
}
|
16046
|
+
}
|
16047
|
+
]
|
16048
|
+
}
|
16049
|
+
sheets_service.spreadsheets().batchUpdate(
|
16050
|
+
spreadsheetId=dataroom_folder_id,
|
16051
|
+
body=rename_request
|
16052
|
+
).execute()
|
16053
|
+
|
16054
|
+
# 4) Читаем CSV-файл (r1) целиком и собираем список строк
|
16017
16055
|
with open(r1, newline='', encoding='utf-8') as csvfile:
|
16018
16056
|
reader = csv.reader(csvfile)
|
16019
16057
|
all_rows = list(reader)
|
16020
16058
|
|
16021
|
-
#
|
16022
|
-
|
16023
|
-
|
16024
|
-
|
16025
|
-
|
16026
|
-
|
16027
|
-
|
16028
|
-
|
16029
|
-
|
16030
|
-
|
16031
|
-
|
16032
|
-
|
16033
|
-
|
16034
|
-
|
16035
|
-
|
16059
|
+
# 5) Пишем значения из all_rows в только что переименованный лист (PROJECT_USERNAME), начиная с A1
|
16060
|
+
write_body = {
|
16061
|
+
'valueInputOption': 'USER_ENTERED',
|
16062
|
+
'data': [
|
16063
|
+
{
|
16064
|
+
'range': f"{PROJECT_USERNAME}!A1",
|
16065
|
+
'majorDimension': 'ROWS',
|
16066
|
+
'values': all_rows
|
16067
|
+
}
|
16068
|
+
]
|
16069
|
+
}
|
16070
|
+
sheets_service.spreadsheets().values().batchUpdate(
|
16071
|
+
spreadsheetId=dataroom_folder_id,
|
16072
|
+
body=write_body
|
16073
|
+
).execute()
|
16074
|
+
logger.info("Activity‐метрики (r1) успешно загружены в Google‐таблицу.")
|
16036
16075
|
else:
|
16037
|
-
logger.warning(f"
|
16076
|
+
logger.warning(f"Файл с метриками не найден или не существует: {r1}")
|
16077
|
+
|
16038
16078
|
except Exception as e:
|
16039
16079
|
logger.info(log_ % str(e))
|
16040
16080
|
await asyncio.sleep(round(random.uniform(0, 1), 2))
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|