datamarket 0.9.47__py3-none-any.whl → 0.9.49__py3-none-any.whl

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.

Potentially problematic release.


This version of datamarket might be problematic. Click here for more details.

@@ -18,13 +18,9 @@ class DriveInterface:
18
18
  if "drive" in config:
19
19
  self.config = config["drive"]
20
20
 
21
- GoogleAuth.DEFAULT_SETTINGS[
22
- "client_config_file"
23
- ] = f'{self.config["config_path"]}/credentials.json'
21
+ GoogleAuth.DEFAULT_SETTINGS["client_config_file"] = f"{self.config['config_path']}/credentials.json"
24
22
 
25
- self.gauth = GoogleAuth(
26
- settings_file=f'{self.config["config_path"]}/settings.yaml'
27
- )
23
+ self.gauth = GoogleAuth(settings_file=f"{self.config['config_path']}/settings.yaml")
28
24
  self.gauth.LocalWebserverAuth()
29
25
 
30
26
  self.drive = GoogleDrive(self.gauth)
@@ -48,24 +44,78 @@ class DriveInterface:
48
44
  logger.info(f"deleting old {filename}...")
49
45
  drive_file.Delete(param={"supportsTeamDrives": True})
50
46
 
47
+ def _create_remote_dir_tree(self, base_folder_id, path_parts):
48
+ """
49
+ Ensure the nested folders described by path_parts exist under base_folder_id.
50
+ Returns the folder_id of the deepest folder (or base_folder_id if path_parts is empty).
51
+ """
52
+ parent_id = base_folder_id
53
+ for part in path_parts:
54
+ part = part.strip()
55
+ if not part:
56
+ continue
57
+
58
+ query = (
59
+ f"'{parent_id}' in parents and title = '{part}'"
60
+ " and mimeType = 'application/vnd.google-apps.folder' and trashed=false"
61
+ )
62
+ results = self.drive.ListFile(
63
+ {
64
+ "q": query,
65
+ "corpora": "teamDrive",
66
+ "teamDriveId": self.team_id,
67
+ "includeTeamDriveItems": True,
68
+ "supportsTeamDrives": True,
69
+ }
70
+ ).GetList()
71
+
72
+ if results:
73
+ parent_id = results[0]["id"]
74
+ else:
75
+ folder_metadata = {
76
+ "title": part,
77
+ "mimeType": "application/vnd.google-apps.folder",
78
+ "parents": [
79
+ {
80
+ "kind": "drive#fileLink",
81
+ "teamDriveId": self.team_id,
82
+ "id": parent_id,
83
+ }
84
+ ],
85
+ }
86
+ folder = self.drive.CreateFile(folder_metadata)
87
+ folder.Upload(param={"supportsTeamDrives": True})
88
+ parent_id = folder["id"]
89
+
90
+ return parent_id
91
+
51
92
  def upload_file(self, local_filename, drive_filename, folder_id):
52
- self.delete_old_files(drive_filename, folder_id)
93
+ drive_filename = drive_filename.strip("/")
94
+ parts = drive_filename.split("/")
95
+ if len(parts) > 1:
96
+ *folders, filename = parts
97
+ target_folder_id = self._create_remote_dir_tree(folder_id, folders)
98
+ else:
99
+ filename = parts[0]
100
+ target_folder_id = folder_id
101
+
102
+ self.delete_old_files(filename, target_folder_id)
53
103
 
54
104
  f = self.drive.CreateFile(
55
105
  {
56
- "title": drive_filename,
106
+ "title": filename,
57
107
  "parents": [
58
108
  {
59
109
  "kind": "drive#fileLink",
60
110
  "teamDriveId": self.team_id,
61
- "id": folder_id,
111
+ "id": target_folder_id,
62
112
  }
63
113
  ],
64
114
  }
65
115
  )
66
116
  f.SetContentFile(local_filename)
67
117
 
68
- logger.info(f"uploading {drive_filename} to folder: {folder_id}...")
118
+ logger.info(f"uploading {drive_filename} to folder: {target_folder_id}...")
69
119
  f.Upload(param={"supportsTeamDrives": True})
70
120
 
71
121
  def validate_file(self, filename, folder_id):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: datamarket
3
- Version: 0.9.47
3
+ Version: 0.9.49
4
4
  Summary: Utilities that integrate advanced scraping knowledge into just one library.
5
5
  License: GPL-3.0-or-later
6
6
  Author: DataMarket
@@ -34,6 +34,7 @@ Provides-Extra: html2text
34
34
  Provides-Extra: httpx
35
35
  Provides-Extra: json5
36
36
  Provides-Extra: lxml
37
+ Provides-Extra: matplotlib
37
38
  Provides-Extra: nodriver
38
39
  Provides-Extra: openpyxl
39
40
  Provides-Extra: pandarallel
@@ -90,6 +91,7 @@ Requires-Dist: jellyfish (>=1.0.0,<2.0.0)
90
91
  Requires-Dist: jinja2 (>=3.0.0,<4.0.0)
91
92
  Requires-Dist: json5 (>=0.10.0,<0.11.0) ; extra == "json5"
92
93
  Requires-Dist: lxml[html-clean] (>=5.0.0,<6.0.0) ; extra == "lxml"
94
+ Requires-Dist: matplotlib (>=3.0.0,<4.0.0) ; extra == "matplotlib"
93
95
  Requires-Dist: nodriver (>=0.44,<0.45) ; extra == "nodriver"
94
96
  Requires-Dist: numpy (>=2.0.0,<3.0.0)
95
97
  Requires-Dist: openpyxl (>=3.0.0,<4.0.0) ; extra == "openpyxl"
@@ -4,7 +4,7 @@ datamarket/exceptions/main.py,sha256=MP5ql6M7DoMbBf-Dg_2ohcUFdWXgzv-dXHntPPit31s
4
4
  datamarket/interfaces/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  datamarket/interfaces/alchemy.py,sha256=mQwjDqBpz1QHRV2JTCALvn5iK_ky69oE2Gw-EtRXsqQ,14664
6
6
  datamarket/interfaces/aws.py,sha256=7KLUeBxmPN7avEMPsu5HC_KHB1N7W6Anp2X8fo43mlw,2383
7
- datamarket/interfaces/drive.py,sha256=shbV5jpQVe_KPE-8Idx6Z9te5Zu1SmVfrvSAyd9ZIgE,2915
7
+ datamarket/interfaces/drive.py,sha256=3nhx3THr2SHNWKYwme9F2nPpvsqyEMFIxz0whF2FjHk,4840
8
8
  datamarket/interfaces/ftp.py,sha256=o0KlJxtksbop9OjCiQRzyAa2IeG_ExVXagS6apwrAQo,1881
9
9
  datamarket/interfaces/nominatim.py,sha256=HLk0FcdfbOVCF_i71l-Hlb17swL0W1a3Gg2n5OLD0tM,15507
10
10
  datamarket/interfaces/peerdb.py,sha256=cwYwvO740GyaPo9zLAwJsf3UeJDGDiYzjQVM9Q6s-_g,23652
@@ -26,7 +26,7 @@ datamarket/utils/strings/normalization.py,sha256=QLZ-THzjGOK9eWPPR1PrsffwQkSOx_M
26
26
  datamarket/utils/strings/obfuscation.py,sha256=8gMepfjPq0N4_IpKR6i2dy_9VJugQ3qJiRiRvKavB3s,5246
27
27
  datamarket/utils/typer.py,sha256=FDF3l6gh3UlAFPsHCtesnekvct2rKz0oFn3uKARBQvE,814
28
28
  datamarket/utils/types.py,sha256=vxdQZdwdXrfPR4Es52gBgol-tMRIOD6oK9cBo3rB0JQ,74
29
- datamarket-0.9.47.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
30
- datamarket-0.9.47.dist-info/METADATA,sha256=f3pGeAGcpzaLmudlSnuFPiLUaq-VVXSfDM4AjYnuzE0,7232
31
- datamarket-0.9.47.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
32
- datamarket-0.9.47.dist-info/RECORD,,
29
+ datamarket-0.9.49.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
30
+ datamarket-0.9.49.dist-info/METADATA,sha256=p0SoJ9ST9H6bBvoyEATxbOau5b-DDviXBFTf2-WlDM8,7326
31
+ datamarket-0.9.49.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
32
+ datamarket-0.9.49.dist-info/RECORD,,