micress-micpy 0.2.14b0__py3-none-any.whl → 0.2.15b0__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.
micpy/bin.py CHANGED
@@ -631,67 +631,67 @@ class File:
631
631
  if self._verbose:
632
632
  print(*args, file=sys.stderr)
633
633
 
634
- def open(self):
635
- """Open the file."""
636
- if not self._file:
637
- self._file = open(self._filename, "rb")
638
- self._compressed = utils.is_compressed(self._filename)
639
-
640
- return self
634
+ def _open_file(self):
635
+ self._file = open(self._filename, "rb")
636
+ self._compressed = utils.is_compressed(self._filename)
641
637
 
642
- def close(self):
643
- """Close the file."""
638
+ def _close_file(self):
644
639
  if self._file:
645
640
  self._file.close()
641
+ self._reset()
646
642
 
643
+ def _reset(self):
647
644
  self._file = None
648
645
  self._compressed = None
649
646
  self._created = None
650
647
  self._modified = None
651
648
  self._index = None
652
649
 
653
- def index(self, create: bool = None, update: bool = None) -> Index:
654
- """Build an index of the file.
655
-
656
- Args:
657
- create (bool, optional): Create the index. Defaults to None (auto).
658
- update (bool, optional): Update the index. Defaults to None (auto).
659
-
660
- Returns:
661
- Index: Index of the file.
662
- """
650
+ def _update_timestamps(self):
651
+ self._created = os.path.getctime(self._filename)
652
+ self._modified = os.path.getmtime(self._filename)
663
653
 
664
- def file_created():
665
- return self._created != os.path.getctime(self._filename)
666
-
667
- def file_modified():
668
- return self._modified != os.path.getmtime(self._filename)
669
-
670
- create = create if create is not None else file_created()
671
- update = update if update is not None else file_modified()
672
-
673
- if create:
674
- self.close()
675
- self.open()
654
+ def open(self):
655
+ """Open the file."""
656
+ if not self._file:
657
+ self.create_index()
658
+ return self
676
659
 
677
- if create or update:
678
- self._created = os.path.getctime(self._filename)
679
- self._modified = os.path.getmtime(self._filename)
660
+ def close(self):
661
+ """Close the file."""
662
+ self._close_file()
663
+
664
+ def index(self):
665
+ """Get the index of the file."""
666
+ if self._created != os.path.getctime(self._filename):
667
+ self.create_index()
668
+ elif self._modified != os.path.getmtime(self._filename):
669
+ self.update_index()
670
+ return self._index
680
671
 
681
- index_params = dict(
682
- file=self._file,
683
- compressed=self._compressed,
684
- chunk_size=self._chunk_size,
672
+ def create_index(self):
673
+ """Create an index of the file."""
674
+ self._close_file()
675
+ self._open_file()
676
+ self._update_timestamps()
677
+ self._index = Index.from_file(
678
+ self._file,
685
679
  verbose=self._verbose,
680
+ chunk_size=self._chunk_size,
681
+ compressed=self._compressed,
686
682
  )
687
683
 
688
- if create:
689
- self._index = Index.from_file(**index_params)
690
- elif update:
691
- index = Index.from_file(**index_params, position=self._index[-1])
692
- self._index.extend(index)
693
-
694
- return self._index
684
+ def update_index(self):
685
+ """Update the index of the file."""
686
+ self._update_timestamps()
687
+ index = Index.from_file(
688
+ self._file,
689
+ verbose=self._verbose,
690
+ chunk_size=self._chunk_size,
691
+ compressed=self._compressed,
692
+ position=self._index[-1],
693
+ )
694
+ self._index.extend(index)
695
695
 
696
696
  def times(self) -> List[float]:
697
697
  """Get the times of the fields in the file.
micpy/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.2.14b0"
1
+ __version__ = "0.2.15b0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: micress-micpy
3
- Version: 0.2.14b0
3
+ Version: 0.2.15b0
4
4
  Summary: MicPy is a Python package to facilitate MICRESS workflows.
5
5
  Author: Lukas Koschmieder
6
6
  Author-email: l.koschmieder@access-technology.de
@@ -0,0 +1,12 @@
1
+ micpy/__init__.py,sha256=7wQUaseppjQYZW1iAVNm2WSDjvBLlqtY8tiHsfDaW5Q,148
2
+ micpy/bin.py,sha256=0RB4FTad00sriZvQdHuTvkzT9D4_pLS_eFwpYS7EOhA,26492
3
+ micpy/geo.py,sha256=dcXcxvAxPpe4Rrs1ImYs8H67c2228brabdefJMoLn0g,7354
4
+ micpy/matplotlib.py,sha256=toxFTtTaA-usuWUltMp0XufQee4-n68XH7SN2In2NZY,1845
5
+ micpy/tab.py,sha256=ZXhL6bg17W3jqFFX28htCOAV9W_W3op_-GD7iU5a_wY,3547
6
+ micpy/utils.py,sha256=Kt1AvhMvWer9uftbb88X7N27aXtQdJl26grHmmm2vOQ,859
7
+ micpy/version.py,sha256=tyiEmp3lrfZHINaXvAGtz6wbg_fRgizg1D1jsMt3PXo,26
8
+ micress_micpy-0.2.15b0.dist-info/LICENSE,sha256=seHdCiArizUoWZ6bEFg6N3K2ZtfPK35wvOwg0kH-f6o,1488
9
+ micress_micpy-0.2.15b0.dist-info/METADATA,sha256=Po-1cfNOIsV2m9wU_oj8kKzf2LllWQf-50PQD5O_g3c,3824
10
+ micress_micpy-0.2.15b0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
11
+ micress_micpy-0.2.15b0.dist-info/top_level.txt,sha256=RiopkpW0AGNYdtOW2eQUWgm3yHGC13q9pWlHb2alhiE,6
12
+ micress_micpy-0.2.15b0.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- micpy/__init__.py,sha256=7wQUaseppjQYZW1iAVNm2WSDjvBLlqtY8tiHsfDaW5Q,148
2
- micpy/bin.py,sha256=VHh9JPJAr0jjFJnyPLO-kIO1AdEuQgBun8oakLOpaoM,26534
3
- micpy/geo.py,sha256=dcXcxvAxPpe4Rrs1ImYs8H67c2228brabdefJMoLn0g,7354
4
- micpy/matplotlib.py,sha256=toxFTtTaA-usuWUltMp0XufQee4-n68XH7SN2In2NZY,1845
5
- micpy/tab.py,sha256=ZXhL6bg17W3jqFFX28htCOAV9W_W3op_-GD7iU5a_wY,3547
6
- micpy/utils.py,sha256=Kt1AvhMvWer9uftbb88X7N27aXtQdJl26grHmmm2vOQ,859
7
- micpy/version.py,sha256=hNVzjX1MyH60RwPXe8_zwZd7WsxPBh2PKFtmqeYKn_Y,26
8
- micress_micpy-0.2.14b0.dist-info/LICENSE,sha256=seHdCiArizUoWZ6bEFg6N3K2ZtfPK35wvOwg0kH-f6o,1488
9
- micress_micpy-0.2.14b0.dist-info/METADATA,sha256=2kD96oel2I-27Of19SvAh6kKYTpKrNInKrR9pw0nwtY,3824
10
- micress_micpy-0.2.14b0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
11
- micress_micpy-0.2.14b0.dist-info/top_level.txt,sha256=RiopkpW0AGNYdtOW2eQUWgm3yHGC13q9pWlHb2alhiE,6
12
- micress_micpy-0.2.14b0.dist-info/RECORD,,