datakit-data 0.7.1__tar.gz → 0.7.2__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,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: datakit-data
3
- Version: 0.7.1
3
+ Version: 0.7.2
4
4
  Summary: A datakit plugin to manage data assets on AWS S3.
5
5
  Author: Larry Fenn
6
6
  Author-email: Larry Fenn <lfenn@ap.org>
@@ -1,6 +1,6 @@
1
1
  __author__ = """Larry Fenn"""
2
2
  __email__ = 'lfenn@ap.org'
3
- __version__ = '0.7.1'
3
+ __version__ = '0.7.2'
4
4
 
5
5
  from .commands.init import Init
6
6
  from .commands.push import Push
@@ -8,6 +8,7 @@ from ..project_mixin import ProjectMixin
8
8
  from ..s3 import S3, list_local_files
9
9
  from ..sync_markers import SyncMarkers
10
10
 
11
+
11
12
  class Status(ProjectMixin, CommandHelpers, Command):
12
13
 
13
14
  "Show sync status of local data files"
@@ -50,6 +51,7 @@ class Status(ProjectMixin, CommandHelpers, Command):
50
51
  configs = read_json(self.project_config_path)
51
52
  configs['sync_status_location'] = '.sync_status/'
52
53
  write_json(self.project_config_path, configs)
54
+ self._add_to_gitignore('.sync_status/')
53
55
  self.log.info("Added sync_status_location to config/datakit-data.json")
54
56
  return
55
57
  missing, stale = self._find_unsynced('data/', markers)
@@ -57,6 +59,28 @@ class Status(ProjectMixin, CommandHelpers, Command):
57
59
  self._log_group("file(s) missing a .synced file", missing, parsed_args.filepaths)
58
60
  self._log_group("file(s) modified since last sync", stale, parsed_args.filepaths)
59
61
 
62
+ def _add_to_gitignore(self, directory):
63
+ gitignore_path = '.gitignore'
64
+ try:
65
+ with open(gitignore_path, encoding='utf-8') as gitignore:
66
+ contents = gitignore.read()
67
+ except FileNotFoundError:
68
+ contents = ''
69
+
70
+ entry = f"{directory.rstrip('/')}/"
71
+ existing_entries = {
72
+ line.strip().rstrip('/')
73
+ for line in contents.splitlines()
74
+ if line.strip() and not line.lstrip().startswith('#')
75
+ }
76
+ if entry.rstrip('/') in existing_entries:
77
+ return
78
+
79
+ with open(gitignore_path, 'a', encoding='utf-8') as gitignore:
80
+ if contents and not contents.endswith('\n'):
81
+ gitignore.write('\n')
82
+ gitignore.write(f'{entry}\n')
83
+
60
84
  def _report_s3_comparison(self, sync_status_dir, filepaths):
61
85
  bucket = self.project_configs['s3_bucket']
62
86
  if bucket == "":
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "datakit-data"
7
- version = "0.7.1"
7
+ version = "0.7.2"
8
8
  description = "A datakit plugin to manage data assets on AWS S3."
9
9
  authors = [
10
10
  {name = "Larry Fenn", email = "lfenn@ap.org"},