text
stringlengths
0
828
""""""
Get index of the parameter.
:param item: Item for which get the index.
:return: Index of the parameter in the WeakList.
""""""
return list.index(self, self.ref(item), **kwargs)"
3925,"def insert(self, index, item):
# type: (int, Any) -> None
""""""
Insert item at the specific index.
:param index: Index where to insert the item.
:param item: Item to insert.
""""""
return list.insert(self, index, self.ref(item))"
3926,"def sort(self, *, key: Optional[Callable[[Any], Any]] = None, reverse: bool = False) -> None:
""""""
Sort _WeakList.
:param key: Key by which to sort, default None.
:param reverse: True if return reversed WeakList, false by default.
""""""
return list.sort(self, key=self._sort_key(key), reverse=reverse)"
3927,"def get_feed(self, datasource_id):
""""""
Получение настроек для фида
:param datasource_id: идентификатор фида
:return: FeedDataSource
""""""
info = self.__metadb.one(
""""""
SELECT to_json(ds) as datasource
, to_json(fc) as connector
, to_json(fct) as connector_type
, to_json(ctp) as connector_type_preset
, json_build_object('email', u.email, 'full_name', u.full_name) as author_user
FROM meta.feed_datasource ds
LEFT JOIN meta.feed_connector fc
ON fc.id=ds.connector_id
LEFT JOIN meta.feed_connector_type fct
ON fct.id=fc.connector_type_id
LEFT JOIN meta.feed_connector_type_preset ctp
ON ctp.id=ds.connector_type_preset_id
LEFT JOIN meta.user_list u
ON u.id=ds.author_user_id
WHERE ds.id = :datasource_id::uuid
"""""",
{""datasource_id"": datasource_id}
)
return FeedDataSource(**info)"
3928,"def get_data(self, datasource, callback):
""""""
Сохранение медиафайла
:param task:
:param media_metadata:
:param file_suffix:
:param callback:
:return:
""""""
task = self.__app.worker.current_task
media_metadata = datasource.connector_type_preset['preset_data']['media_metadata']
result_data = task['result_data']
tmp_file = NamedTemporaryFile(delete=False, suffix=SOURCE_FORMAT_EXTENSION.get(media_metadata['sourceFormat']))
self.__app.log.info(""Открываем файл"", {""filename"": tmp_file.name})
with open(tmp_file.name, 'wb') as f:
callback(f)
self.__app.log.info(""start media upload"")
result_data['stage_id'] = ""persist_media_file""
self.__starter.update_task_result_data(task)
result = self.__media.upload(open(tmp_file.name), {
""ttlInSec"": 60 * 60 * 24, # 24h
""entityId"": 2770,
""objectId"": task.get('data', {}).get(""ds_id""),
""info"": {""metadata"": media_metadata}
})
result_data['stage_id'] = ""generate_media_finish""
result_data['media_id'] = result['id']
self.__starter.update_task_result_data(task)
return result"
3929,"def datasource_process(self, datasource_id):
""""""
deprecated
Запускает настроенные обработки в фиде
:param datasource_id: uuid
""""""
# TODO Выпилить потом класс используется для другого
# TODO без applicationId не выбираются поля сущностей. Подумать на сколько это НЕ нормально
response = self.__app.native_api_call('feed', 'datasource/' + datasource_id + '/process?applicationId=1', {},
self.__options, False, None, False, http_method=""POST"")
return json.loads(response.text)"
3930,"def _delta_dir():
""""""returns the relative path of the current directory to the git
repository.
This path will be added the 'filename' path to find the file.
It current_dir is the git root, this function returns an empty string.
Keyword Arguments:
<none>