Skip to content

Commit 5502716

Browse files
committed
Code cleanup
1 parent f87c866 commit 5502716

File tree

3 files changed

+16
-35
lines changed

3 files changed

+16
-35
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ If you only care about the command line tool, I recommend installing with [pipx]
3434
The command line tool can also be run via `python -m osxmetadata`. Running it with no arguments or with --help option will print a help message:
3535

3636
```
37-
Usage: python -m osxmetadata [OPTIONS] FILE
37+
Usage: osxmetadata [OPTIONS] FILE
3838
3939
Read/write metadata from file(s).
4040
@@ -141,6 +141,13 @@ downloadeddate kMDItemDownloadedDate,
141141
zone), or 2020-04-14T12:00:00-07:00 (ISO 8601 with timezone
142142
offset). Times without timezone offset are assumed to be in
143143
local timezone.
144+
duedate kMDItemDueDate, com.apple.metadata:kMDItemDueDate; The date
145+
the item is due. A date in ISO 8601 format, time and
146+
timezone offset are optional: e.g. 2020-04-14T12:00:00 (ISO
147+
8601 w/o timezone), 2020-04-14 (ISO 8601 w/o time and time
148+
zone), or 2020-04-14T12:00:00-07:00 (ISO 8601 with timezone
149+
offset). Times without timezone offset are assumed to be in
150+
local timezone.
144151
findercomment kMDItemFinderComment,
145152
com.apple.metadata:kMDItemFinderComment; Finder comments for
146153
this file. A string.
@@ -159,6 +166,9 @@ keywords kMDItemKeywords, com.apple.metadata:kMDItemKeywords;
159166
(_kMDItemUserTags) which are keywords/tags shown in the
160167
Finder and searchable in Spotlight using "tag:tag_name". A
161168
list of strings.
169+
rating kMDItemStarRating, com.apple.metadata:kMDItemStarRating;
170+
User rating of this item. For example, the stars rating of
171+
an iTunes track. An integer.
162172
tags _kMDItemUserTags, com.apple.metadata:_kMDItemUserTags;
163173
Finder tags; searchable in Spotlight using "tag:tag_name".
164174
If you want tags/keywords visible in the Finder, use this

osxmetadata/attributes.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
import datetime
5-
import logging
65
from collections import namedtuple # pylint: disable=syntax-error
76

87
from .classes import _AttributeFinderInfo, _AttributeList, _AttributeTagsList
@@ -268,30 +267,9 @@
268267
False,
269268
False,
270269
"User rating of this item. "
271-
+ "For example, the stars rating of an iTunes track. An int.",
270+
+ "For example, the stars rating of an iTunes track. An integer.",
272271
None,
273272
)
274-
# "test": Attribute(
275-
# "test",
276-
# "com.osxmetadata.test:DontTryThisAtHomeKids",
277-
# "com.osxmetadata.test:DontTryThisAtHomeKids",
278-
# datetime.datetime,
279-
# False,
280-
# False,
281-
# datetime.datetime,
282-
# "Don't try this at home",
283-
# ),
284-
# "test_float": Attribute(
285-
# "test_float",
286-
# "com.osxmetadata.test:DontTryThisAtHomeKids",
287-
# float,
288-
# False,
289-
# False,
290-
# float,
291-
# ),
292-
# "test_str": Attribute(
293-
# "test_str", "com.osxmetadata.test:String", str, False, False, str
294-
# ),
295273
}
296274

297275
# used for formatting output of --list
@@ -334,14 +312,6 @@ def validate_attribute_value(attribute, value):
334312
except TypeError:
335313
value = [value]
336314

337-
# # check for None and convert to list if needed
338-
# if not isinstance(value, list):
339-
# if value is None:
340-
# return None
341-
# value = [value]
342-
# elif None in value:
343-
# return None
344-
345315
if not attribute.list and len(value) > 1:
346316
# got a list but didn't expect one
347317
raise ValueError(

osxmetadata/osxmetadata.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import os.path
99
import pathlib
1010
import plistlib
11-
import sys
1211
import base64
1312

1413
# plistlib creates constants at runtime which causes pylint to complain
@@ -42,6 +41,7 @@
4241
kMDItemUserTags,
4342
kMDItemWhereFroms,
4443
kMDItemDueDate,
44+
kMDItemStarRating,
4545
)
4646
from .datetime_utils import (
4747
datetime_naive_to_utc,
@@ -120,6 +120,7 @@ class OSXMetaData:
120120
"wherefroms",
121121
"finderinfo",
122122
"duedate",
123+
"rating",
123124
]
124125

125126
def __init__(self, fname, tz_aware=False):
@@ -222,7 +223,7 @@ def asdict(self, all_=False, encode=True):
222223

223224
def to_json(self, all_=False):
224225
"""Returns a string in JSON format for all attributes in this file
225-
226+
226227
Args:
227228
all_: bool; if True, also restores attributes not known to osxmetadata (generated with asdict(all_=True, encode=True) )
228229
"""
@@ -553,7 +554,7 @@ def clear_finder_comment(self, path):
553554
pass
554555

555556
def __getattr__(self, name):
556-
"""if attribute name is in ATTRIBUTE dict, return the value """
557+
"""if attribute name is in ATTRIBUTE dict, return the value"""
557558
if name in ATTRIBUTES:
558559
return self.get_attribute(name)
559560
raise AttributeError(f"{name} is not an attribute")

0 commit comments

Comments
 (0)