mac-alias 2.0.0__tar.gz → 2.0.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.
- {mac_alias-2.0.0 → mac_alias-2.0.2}/PKG-INFO +19 -2
- {mac_alias-2.0.0 → mac_alias-2.0.2}/README.rst +17 -0
- {mac_alias-2.0.0 → mac_alias-2.0.2}/mac_alias/alias.py +11 -7
- {mac_alias-2.0.0 → mac_alias-2.0.2}/mac_alias/bookmark.py +19 -7
- {mac_alias-2.0.0 → mac_alias-2.0.2}/mac_alias/osx.py +5 -1
- {mac_alias-2.0.0 → mac_alias-2.0.2}/mac_alias.egg-info/PKG-INFO +19 -2
- {mac_alias-2.0.0 → mac_alias-2.0.2}/setup.py +20 -2
- {mac_alias-2.0.0 → mac_alias-2.0.2}/mac_alias/__init__.py +0 -0
- {mac_alias-2.0.0 → mac_alias-2.0.2}/mac_alias/utils.py +0 -0
- {mac_alias-2.0.0 → mac_alias-2.0.2}/mac_alias.egg-info/SOURCES.txt +0 -0
- {mac_alias-2.0.0 → mac_alias-2.0.2}/mac_alias.egg-info/dependency_links.txt +0 -0
- {mac_alias-2.0.0 → mac_alias-2.0.2}/mac_alias.egg-info/top_level.txt +0 -0
- {mac_alias-2.0.0 → mac_alias-2.0.2}/setup.cfg +0 -0
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
Metadata-Version: 1.1
|
|
2
2
|
Name: mac_alias
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: Generate/parse Mac OS Alias records from Python
|
|
5
5
|
Home-page: http://alastairs-place.net/projects/mac_alias
|
|
6
6
|
Author: Alastair Houghton
|
|
7
7
|
Author-email: alastair@alastairs-place.net
|
|
8
8
|
License: MIT License
|
|
9
|
-
Description:
|
|
9
|
+
Description: =========
|
|
10
|
+
mac_alias
|
|
11
|
+
=========
|
|
12
|
+
|
|
13
|
+
.. image:: https://travis-ci.org/al45tair/mac_alias.svg?branch=master
|
|
14
|
+
:target: https://travis-ci.org/al45tair/mac_alias
|
|
15
|
+
|
|
16
|
+
.. image:: https://readthedocs.org/projects/mac_alias/badge/?version=latest
|
|
17
|
+
:target: http://mac_alias.readthedocs.io/en/latest/?badge=latest
|
|
18
|
+
|
|
19
|
+
What is this?
|
|
20
|
+
-------------
|
|
21
|
+
|
|
22
|
+
``mac_alias`` lets you generate or read binary Alias and Bookmark records
|
|
10
23
|
from Python code.
|
|
11
24
|
|
|
12
25
|
While it is written in pure Python, some OS X specific code is required to
|
|
@@ -18,6 +31,10 @@ Description: ``mac_alias`` lets you generate or read binary Alias and Bookmark r
|
|
|
18
31
|
<alastair@alastairs-place.net> was responsible for reverse engineering the
|
|
19
32
|
bookmark format.
|
|
20
33
|
|
|
34
|
+
See the documentation_ for more information.
|
|
35
|
+
|
|
36
|
+
.. _documentation:: http://mac-alias.rtfd.org
|
|
37
|
+
|
|
21
38
|
Platform: darwin
|
|
22
39
|
Classifier: Development Status :: 5 - Production/Stable
|
|
23
40
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
=========
|
|
2
|
+
mac_alias
|
|
3
|
+
=========
|
|
4
|
+
|
|
5
|
+
.. image:: https://travis-ci.org/al45tair/mac_alias.svg?branch=master
|
|
6
|
+
:target: https://travis-ci.org/al45tair/mac_alias
|
|
7
|
+
|
|
8
|
+
.. image:: https://readthedocs.org/projects/mac_alias/badge/?version=latest
|
|
9
|
+
:target: http://mac_alias.readthedocs.io/en/latest/?badge=latest
|
|
10
|
+
|
|
11
|
+
What is this?
|
|
12
|
+
-------------
|
|
13
|
+
|
|
1
14
|
``mac_alias`` lets you generate or read binary Alias and Bookmark records
|
|
2
15
|
from Python code.
|
|
3
16
|
|
|
@@ -9,3 +22,7 @@ Credit is due to Wim Lewis <wiml@hhhh.org>, whose work on reverse engineering
|
|
|
9
22
|
the alias format was extremely useful in writing this code. Alastair Houghton
|
|
10
23
|
<alastair@alastairs-place.net> was responsible for reverse engineering the
|
|
11
24
|
bookmark format.
|
|
25
|
+
|
|
26
|
+
See the documentation_ for more information.
|
|
27
|
+
|
|
28
|
+
.. _documentation:: http://mac-alias.rtfd.org
|
|
@@ -323,6 +323,9 @@ class Alias (object):
|
|
|
323
323
|
"""Create an :class:`Alias` that points at the specified file."""
|
|
324
324
|
if sys.platform != 'darwin':
|
|
325
325
|
raise Exception('Not implemented (requires special support)')
|
|
326
|
+
|
|
327
|
+
if not isinstance(path, bytes):
|
|
328
|
+
path = path.encode('utf-8')
|
|
326
329
|
|
|
327
330
|
a = Alias()
|
|
328
331
|
|
|
@@ -337,7 +340,7 @@ class Alias (object):
|
|
|
337
340
|
volinfo = osx.getattrlist(vol_path, attrs, 0)
|
|
338
341
|
|
|
339
342
|
vol_crtime = volinfo[0]
|
|
340
|
-
vol_name = volinfo[1]
|
|
343
|
+
vol_name = volinfo[1].encode('utf-8')
|
|
341
344
|
|
|
342
345
|
# Also grab various attributes of the file
|
|
343
346
|
attrs = [(osx.ATTR_CMN_OBJTYPE
|
|
@@ -357,7 +360,7 @@ class Alias (object):
|
|
|
357
360
|
|
|
358
361
|
dirname, filename = os.path.split(path)
|
|
359
362
|
|
|
360
|
-
if dirname == '' or dirname == '.':
|
|
363
|
+
if dirname == b'' or dirname == b'.':
|
|
361
364
|
dirname = os.getcwd()
|
|
362
365
|
|
|
363
366
|
foldername = os.path.basename(dirname)
|
|
@@ -382,10 +385,10 @@ class Alias (object):
|
|
|
382
385
|
rel_path = os.path.relpath(path, vol_path)
|
|
383
386
|
|
|
384
387
|
# Leave off the initial '/' if vol_path is '/' (no idea why)
|
|
385
|
-
if vol_path == '/':
|
|
388
|
+
if vol_path == b'/':
|
|
386
389
|
a.target.posix_path = rel_path
|
|
387
390
|
else:
|
|
388
|
-
a.target.posix_path = '/' + rel_path
|
|
391
|
+
a.target.posix_path = b'/' + rel_path
|
|
389
392
|
|
|
390
393
|
# Construct the Carbon and CNID paths
|
|
391
394
|
carbon_path = []
|
|
@@ -398,10 +401,11 @@ class Alias (object):
|
|
|
398
401
|
attrs = [osx.ATTR_CMN_FILEID, 0, 0, 0, 0]
|
|
399
402
|
info = osx.getattrlist(os.path.join(vol_path, head), attrs, 0)
|
|
400
403
|
cnid_path.append(info[0])
|
|
401
|
-
carbon_tail = tail.replace(':','/')
|
|
404
|
+
carbon_tail = tail.replace(b':',b'/')
|
|
402
405
|
carbon_path.insert(0, carbon_tail)
|
|
403
406
|
head, tail = os.path.split(head)
|
|
404
|
-
|
|
407
|
+
|
|
408
|
+
carbon_path = vol_name + b':' + b':\0'.join(carbon_path)
|
|
405
409
|
|
|
406
410
|
a.target.carbon_path = carbon_path
|
|
407
411
|
a.target.cnid_path = cnid_path
|
|
@@ -439,7 +443,7 @@ class Alias (object):
|
|
|
439
443
|
|
|
440
444
|
# Excuse the odd order; we're copying Finder
|
|
441
445
|
if self.target.folder_name:
|
|
442
|
-
carbon_foldername = self.target.folder_name.replace(':','/')\
|
|
446
|
+
carbon_foldername = self.target.folder_name.replace(b':',b'/')\
|
|
443
447
|
.encode('utf-8')
|
|
444
448
|
b.write(struct.pack(b'>hh', TAG_CARBON_FOLDER_NAME,
|
|
445
449
|
len(carbon_foldername)))
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# for the old-fashioned alias format. The details of this format were
|
|
5
5
|
# reverse engineered; some things are still not entirely clear.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import unicode_literals
|
|
7
|
+
from __future__ import unicode_literals, print_function
|
|
8
8
|
|
|
9
9
|
import struct
|
|
10
10
|
import uuid
|
|
@@ -13,7 +13,10 @@ import os
|
|
|
13
13
|
import sys
|
|
14
14
|
import pprint
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
try:
|
|
17
|
+
from urlparse import urljoin
|
|
18
|
+
except ImportError:
|
|
19
|
+
from urllib.parse import urljoin
|
|
17
20
|
|
|
18
21
|
if sys.platform == 'darwin':
|
|
19
22
|
from . import osx
|
|
@@ -292,7 +295,7 @@ class Bookmark (object):
|
|
|
292
295
|
elif dtype == BMK_NULL:
|
|
293
296
|
return None
|
|
294
297
|
|
|
295
|
-
print
|
|
298
|
+
print('Unknown data type %08x' % typecode)
|
|
296
299
|
return (typecode, databytes)
|
|
297
300
|
|
|
298
301
|
@classmethod
|
|
@@ -533,7 +536,7 @@ class Bookmark (object):
|
|
|
533
536
|
|
|
534
537
|
# Find the filesystem
|
|
535
538
|
st = osx.statfs(path)
|
|
536
|
-
vol_path = st.f_mntonname
|
|
539
|
+
vol_path = st.f_mntonname.decode('utf-8')
|
|
537
540
|
|
|
538
541
|
# Grab its attributes
|
|
539
542
|
attrs = [osx.ATTR_CMN_CRTIME,
|
|
@@ -580,6 +583,9 @@ class Bookmark (object):
|
|
|
580
583
|
|
|
581
584
|
foldername = os.path.basename(dirname)
|
|
582
585
|
|
|
586
|
+
print(repr(path))
|
|
587
|
+
print(repr(vol_path))
|
|
588
|
+
|
|
583
589
|
rel_path = os.path.relpath(path, vol_path)
|
|
584
590
|
|
|
585
591
|
# Build the path arrays
|
|
@@ -606,6 +612,12 @@ class Bookmark (object):
|
|
|
606
612
|
volprops = Data(struct.pack(b'<QQQ', 0x81 | kCFURLVolumeSupportsPersistentIDs,
|
|
607
613
|
0x13ef | kCFURLVolumeSupportsPersistentIDs, 0))
|
|
608
614
|
|
|
615
|
+
print(repr(name_path))
|
|
616
|
+
print(repr(cnid_path))
|
|
617
|
+
print(repr(fileprops))
|
|
618
|
+
print(repr(vol_path))
|
|
619
|
+
print(repr(vol_name))
|
|
620
|
+
|
|
609
621
|
toc = {
|
|
610
622
|
kBookmarkPath: name_path,
|
|
611
623
|
kBookmarkCNIDPath: cnid_path,
|
|
@@ -622,9 +634,9 @@ class Bookmark (object):
|
|
|
622
634
|
kBookmarkVolumeProperties: volprops,
|
|
623
635
|
kBookmarkCreationOptions: 512,
|
|
624
636
|
kBookmarkWasFileReference: True,
|
|
625
|
-
kBookmarkUserName: '
|
|
626
|
-
kBookmarkUID:
|
|
627
|
-
|
|
637
|
+
kBookmarkUserName: 'unknown',
|
|
638
|
+
kBookmarkUID: 99,
|
|
639
|
+
}
|
|
628
640
|
|
|
629
641
|
if relcount:
|
|
630
642
|
toc[kBookmarkURLLengths] = url_lengths
|
|
@@ -434,7 +434,7 @@ def _datetime_from_timespec(ts):
|
|
|
434
434
|
return unix_epoch + td
|
|
435
435
|
|
|
436
436
|
def _decode_utf8_nul(sz):
|
|
437
|
-
nul = sz.find('\0')
|
|
437
|
+
nul = sz.find(b'\0')
|
|
438
438
|
if nul > -1:
|
|
439
439
|
sz = sz[:nul]
|
|
440
440
|
return sz.decode('utf-8')
|
|
@@ -757,6 +757,8 @@ def _get_errno():
|
|
|
757
757
|
return __error().contents.value
|
|
758
758
|
|
|
759
759
|
def getattrlist(path, attrs, options):
|
|
760
|
+
if not isinstance(path, bytes):
|
|
761
|
+
path = path.encode('utf-8')
|
|
760
762
|
attrs = list(attrs)
|
|
761
763
|
if attrs[1]:
|
|
762
764
|
attrs[1] |= ATTR_VOL_INFO
|
|
@@ -805,6 +807,8 @@ def fgetattrlist(fd, attrs, options):
|
|
|
805
807
|
return _decode_attrlist_result(buf, attrs, options)
|
|
806
808
|
|
|
807
809
|
def statfs(path):
|
|
810
|
+
if not isinstance(path, bytes):
|
|
811
|
+
path = path.encode('utf-8')
|
|
808
812
|
result = struct_statfs()
|
|
809
813
|
ret = _statfs(path, byref(result))
|
|
810
814
|
if ret < 0:
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
Metadata-Version: 1.1
|
|
2
2
|
Name: mac-alias
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: Generate/parse Mac OS Alias records from Python
|
|
5
5
|
Home-page: http://alastairs-place.net/projects/mac_alias
|
|
6
6
|
Author: Alastair Houghton
|
|
7
7
|
Author-email: alastair@alastairs-place.net
|
|
8
8
|
License: MIT License
|
|
9
|
-
Description:
|
|
9
|
+
Description: =========
|
|
10
|
+
mac_alias
|
|
11
|
+
=========
|
|
12
|
+
|
|
13
|
+
.. image:: https://travis-ci.org/al45tair/mac_alias.svg?branch=master
|
|
14
|
+
:target: https://travis-ci.org/al45tair/mac_alias
|
|
15
|
+
|
|
16
|
+
.. image:: https://readthedocs.org/projects/mac_alias/badge/?version=latest
|
|
17
|
+
:target: http://mac_alias.readthedocs.io/en/latest/?badge=latest
|
|
18
|
+
|
|
19
|
+
What is this?
|
|
20
|
+
-------------
|
|
21
|
+
|
|
22
|
+
``mac_alias`` lets you generate or read binary Alias and Bookmark records
|
|
10
23
|
from Python code.
|
|
11
24
|
|
|
12
25
|
While it is written in pure Python, some OS X specific code is required to
|
|
@@ -18,6 +31,10 @@ Description: ``mac_alias`` lets you generate or read binary Alias and Bookmark r
|
|
|
18
31
|
<alastair@alastairs-place.net> was responsible for reverse engineering the
|
|
19
32
|
bookmark format.
|
|
20
33
|
|
|
34
|
+
See the documentation_ for more information.
|
|
35
|
+
|
|
36
|
+
.. _documentation:: http://mac-alias.rtfd.org
|
|
37
|
+
|
|
21
38
|
Platform: darwin
|
|
22
39
|
Classifier: Development Status :: 5 - Production/Stable
|
|
23
40
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
+
import sys
|
|
2
3
|
from setuptools import setup
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
from setuptools.command.test import test as TestCommand
|
|
6
|
+
|
|
7
|
+
class PyTest(TestCommand):
|
|
8
|
+
def finalize_options(self):
|
|
9
|
+
TestCommand.finalize_options(self)
|
|
10
|
+
self.test_args = []
|
|
11
|
+
self.test_suite = True
|
|
12
|
+
|
|
13
|
+
def run_tests(self):
|
|
14
|
+
import pytest
|
|
15
|
+
errno = pytest.main(self.test_args)
|
|
16
|
+
sys.exit(errno)
|
|
17
|
+
|
|
18
|
+
with open('README.rst', 'rb') as f:
|
|
5
19
|
longdesc = f.read().decode('utf-8')
|
|
6
20
|
|
|
7
21
|
setup(name='mac_alias',
|
|
8
|
-
version='2.0.
|
|
22
|
+
version='2.0.2',
|
|
9
23
|
description='Generate/parse Mac OS Alias records from Python',
|
|
10
24
|
long_description=longdesc,
|
|
11
25
|
author='Alastair Houghton',
|
|
@@ -19,4 +33,8 @@ setup(name='mac_alias',
|
|
|
19
33
|
'License :: OSI Approved :: MIT License',
|
|
20
34
|
'Topic :: Desktop Environment',
|
|
21
35
|
'Topic :: Software Development :: Libraries :: Python Modules'],
|
|
36
|
+
tests_require=['pytest'],
|
|
37
|
+
cmdclass={
|
|
38
|
+
'test': PyTest
|
|
39
|
+
},
|
|
22
40
|
provides=['mac_alias'])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|