polyanalyst6api 0.35.3__tar.gz → 0.36.0__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.
@@ -1,28 +1,25 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: polyanalyst6api
3
- Version: 0.35.3
3
+ Version: 0.36.0
4
4
  Summary: polyanalyst6api is a PolyAnalyst API client for Python.
5
- Home-page: https://github.com/Megaputer/polyanalyst6api-py
6
5
  License: MIT
6
+ License-File: LICENSE
7
7
  Keywords: megaputer,polyanalyst,polyanalyst6api,api
8
8
  Author: yatmanov
9
9
  Author-email: yatmanov@megaputer.ru
10
- Requires-Python: >=3.7,<4.0
10
+ Requires-Python: >=3.9,<4.0
11
11
  Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.7
14
- Classifier: Programming Language :: Python :: 3.8
15
13
  Classifier: Programming Language :: Python :: 3.9
16
14
  Classifier: Programming Language :: Python :: 3.10
17
15
  Classifier: Programming Language :: Python :: 3.11
18
16
  Classifier: Programming Language :: Python :: 3.12
19
17
  Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
20
19
  Classifier: Topic :: Internet
21
20
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
21
  Requires-Dist: pytus (>=0.2.1,<0.3.0)
23
- Requires-Dist: requests (>=2.31,<3.0)
24
- Requires-Dist: urllib3 (==1.26.18) ; python_version == "3.7"
25
- Requires-Dist: urllib3 ; python_version >= "3.8"
22
+ Requires-Dist: requests (>=2.32,<3.0)
26
23
  Project-URL: Changelog, https://github.com/Megaputer/polyanalyst6api-py/blob/master/CHANGELOG.md
27
24
  Project-URL: Documentation, https://polyanalyst6api-py.rtfd.io/
28
25
  Project-URL: Repository, https://github.com/Megaputer/polyanalyst6api-py
@@ -1,4 +1,4 @@
1
- __version__ = '0.35.2'
1
+ __version__ = '0.36.0'
2
2
 
3
3
  from .api import *
4
4
  from .exceptions import *
@@ -204,7 +204,7 @@ class API:
204
204
  project_space: Optional[str] = None,
205
205
  on_conflict: str = 'Cancel',
206
206
  wait: bool = False
207
- ) -> Union[str, Dict]:
207
+ ) -> Union[str, Dict]:
208
208
  """
209
209
  Import project from file on server file system.
210
210
 
@@ -254,6 +254,13 @@ class API:
254
254
  if not wait:
255
255
  return import_id
256
256
 
257
+ # Started,
258
+ # Unpacking,
259
+ # CheckingReferences,
260
+ # Error,
261
+ # Imported,
262
+ # Cancelled
263
+
257
264
  while True:
258
265
  time.sleep(1)
259
266
  status = self.get_project_import_status(import_id)
@@ -80,7 +80,7 @@ class Project:
80
80
  task['startTime'] = datetime.datetime.utcfromtimestamp(task['startTime'] / 1000)
81
81
  return json
82
82
 
83
- def save(self) -> None:
83
+ def save(self, wait: bool = False) -> None: # TODO project/save/status do exist
84
84
  """Initiates saving of all changes that have been made in the project."""
85
85
  self.api.post('project/save', json={'prjUUID': self.uuid})
86
86
 
@@ -514,7 +514,7 @@ class Project:
514
514
  Use :meth:`Project.get_execution_stats` instead.
515
515
  """
516
516
  warnings.warn(
517
- 'Project.get_execution_statistics() is deprecated, use' 'Project.get_execution_stats() instead.',
517
+ 'Project.get_execution_statistics() is deprecated, use Project.get_execution_stats() instead.',
518
518
  DeprecationWarning,
519
519
  stacklevel=2,
520
520
  )
@@ -714,12 +714,18 @@ class DataSet:
714
714
 
715
715
  return self._api.get('dataset/preview', params=params)
716
716
 
717
- def iter_rows(self, start: int = 0, stop: Optional[int] = None) -> Iterator[Dict[str, JSON_VAL]]:
717
+ def iter_rows(
718
+ self,
719
+ start: int = 0,
720
+ stop: Optional[int] = None,
721
+ fetch_files: bool = False
722
+ ) -> Iterator[Dict[str, JSON_VAL]]:
718
723
  """
719
724
  Iterate over rows in dataset.
720
725
 
721
- :param start:
722
- :param stop:
726
+ :param start: starting row index. 0 by default (the first row)
727
+ :param stop: ending index. None by default, which means iterates to the last row
728
+ :param fetch_files: whatever to download file attachments as bytes. False by default
723
729
 
724
730
  :raises: ValueError if `start` or `stop` is out of datasets' row range
725
731
 
@@ -742,8 +748,9 @@ class DataSet:
742
748
  if not 0 <= start <= stop <= max_row:
743
749
  raise ValueError(f'start and stop arguments must be within dataset row range: (0, {max_row})')
744
750
 
745
- rows = self._values(stop)['table']
751
+ values = self._values(stop)
746
752
  get_text = self._cell_text
753
+ get_file = self._binary_content
747
754
 
748
755
  class RowIterator:
749
756
  def __init__(self):
@@ -760,10 +767,10 @@ class DataSet:
760
767
  columns = info.get('columnsInfo') or info['columns']
761
768
  for column in columns:
762
769
  if column['flags'].get('getTextAlways'):
763
- result[column['title']] = get_text(self.idx, column['id'])
770
+ _value = get_text(self.idx, column['id'])
764
771
  # elif column['type'] == 'DateTime': # todo convert to python datetime?
765
772
  else:
766
- _value = rows[self.idx][column['id']]
773
+ _value = values['table'][self.idx][column['id']]
767
774
  if _value == 1e100:
768
775
  _value = None
769
776
  elif _value == 8e100:
@@ -771,7 +778,10 @@ class DataSet:
771
778
  elif _value == -8e100:
772
779
  _value = -math.inf
773
780
 
774
- result[column['title']] = _value
781
+ if fetch_files and str(column['id']) in values['binaryContent']:
782
+ _value = get_file(values['textIDs'][str(column['id'])][str(self.idx)], '_')
783
+
784
+ result[column['title']] = _value
775
785
 
776
786
  self.idx += 1
777
787
  return result
@@ -801,3 +811,15 @@ class DataSet:
801
811
  'col': col,
802
812
  },
803
813
  )['text']
814
+
815
+ @retry_on_invalid_guid
816
+ def _binary_content(self, key: str, filename: str) -> bytes:
817
+ return self._api.request(
818
+ 'dataset/get-binary-content',
819
+ method='GET',
820
+ params={
821
+ 'wrapperGuid': self.guid,
822
+ 'key': key,
823
+ 'fileName': filename,
824
+ },
825
+ )[0].content
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "polyanalyst6api"
3
- version = "0.35.3"
3
+ version = "0.36.0"
4
4
  description = "polyanalyst6api is a PolyAnalyst API client for Python."
5
5
  authors = ["yatmanov <yatmanov@megaputer.ru>"]
6
6
  license = "MIT"
@@ -20,13 +20,9 @@ classifiers = [
20
20
  "Changelog" = "https://github.com/Megaputer/polyanalyst6api-py/blob/master/CHANGELOG.md"
21
21
 
22
22
  [tool.poetry.dependencies]
23
- python = "^3.7"
24
- requests = "^2.31"
23
+ python = "^3.9"
24
+ requests = "^2.32"
25
25
  pytus = "^0.2.1"
26
- urllib3 = [
27
- {version = "1.26.18", python = "3.7"},
28
- {version = "*", python = ">=3.8"}
29
- ]
30
26
 
31
27
  [tool.poetry.group.test.dependencies]
32
28
  pytest = "^7.4.0"