woc.local
This type stub file was generated by cyright.
Returns the 32 bit FNV-1a hash value for the given data.
>>> hex(fnvhash('foo'))
'0xa9f37ed7'
Perl BER unpacking. BER is a way to pack several variable-length ints into one binary string. Here we do the reverse. Format definition: from http://perldoc.perl.org/functions/pack.html (see "w" template description)
Parameters
- buf: a binary string with packed values
Returns
a list of unpacked values
>>> unber(b'\x00\x83M')
[0, 461]
>>> unber(b'\x83M\x96\x14')
[461, 2836]
>>> unber(b'\x99a\x89\x12')
[3297, 1170]
Get length of uncompressed data from a header of Compress::LZF output.
Check Compress::LZF sources for the definition of this bit magic: (namely, LZF.xs, decompress_sv) https://metacpan.org/source/MLEHMANN/Compress-LZF-3.8/LZF.xs
Parameters
- **raw_data: data compressed with Perl
Compress:**: LZF
Returns
(header_size, uncompressed_content_length) in bytes
>>> lzf_length(b'\xc4\x9b')
(2, 283)
>>> lzf_length(b'\xc3\xa4')
(2, 228)
>>> lzf_length(b'\xc3\x8a')
(2, 202)
>>> lzf_length(b'\xca\x87')
(2, 647)
>>> lzf_length(b'\xe1\xaf\xa9')
(3, 7145)
>>> lzf_length(b'\xe0\xa7\x9c')
(3, 2524)
lzf wrapper to handle perl tweaks in Compress::LZF
This function extracts uncompressed size header and then does usual lzf decompression.
Parameters
- **raw_data: data compressed with Perl
Compress:**: LZF
Returns
unpacked data
Try to decompress raw_data, return raw_data if it fails
Slice raw_data into 20-byte chunks and hex encode each of them It returns tuple in order to be cacheable
Aggressively decode raw_data, return empty string if it fails
Cache TCHashDB objects
Get shard id
Decode values from tch maps.
Decode a tree binary object into tuples.
Python: 4.77 µs, Cython: 280 ns Reference: https://stackoverflow.com/questions/14790681/
>>> decode_tree(b'100644 .gitignore\x00\x8e\x9e\x1f...')
[('100644', '.gitignore', '8e9e1...'), ...]
Decode git commit objects into tuples.
Python: 2.35 µs, Cython: 855 ns Reference: https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
>>> decode_commit(b'tree f1b66dcca490b5c4455af319bc961a34f69c72c2\n...')
('f1b66dcca490b5c4455af319bc961a34f69c72c2',
('c19ff598808b181f1ab2383ff0214520cb3ec659',),
('Audris Mockus <audris@utk.edu> 1410029988', '1410029988', '-0400'),
('Audris Mockus <audris@utk.edu>', '1410029988', '-0400'),
'News for Sep 5, 2014\n')
Decode git tag objects into tuples.
decode_tag(b'object fcadcb9366d4a011039e384affa10961e99cf2c4 type commit tag eccube-2.11.1 tagger nanasess
1303788649 +0000
Added tags/eccube-2.11.1
')
('fcadcb9366d4a011039e384affa10961e99cf2c4', 'commit', 'eccube-2.11.1', 'nanasess
Read a .large. and return its content.
Parameters
- path: path to the file
- dtype: data type
- offset: offset to start reading. It is either 0 or after the last separator.
- length: length to read. It should be longer than the longest record.
Returns
a tuple of bytes and the next offset, None if EOF. Returned bytes must not begin or end with a separator.
Eqivalent to getValues in WoC Perl API.
>>> self.get_values('P2c', 'user2589_minicms')
['05cf84081b63cda822ee407e688269b494a642de', ...]
Eqivalent to getValues in WoC Perl API.
>>> self.get_values('P2c', 'user2589_minicms')
['05cf84081b63cda822ee407e688269b494a642de', ...]
Eqivalent to showCnt in WoC perl API
>>> self.show_content('tree', '7a374e58c5b9dec5f7508391246c48b73c40d200')
[('100644', '.gitignore', '8e9e1...'), ...]
Iterate over all keys in a map.
>>> for key in self.iter_map('P2c'):
... print(key) # hash or encoded string
Inherited Members
- woc.base.WocMapsBase
- maps
- objects