Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_list_equality(tmpdir):
list1 = List(path=str(tmpdir), name='test list')
list2 = List(path=str(tmpdir), name='test list')
list3 = List(path=str(tmpdir), name='yet another test list')
assert list1 == list2
assert list1 != list3
assert list1 != 'test list'
def test_list_equality(tmpdir):
list1 = List(path=str(tmpdir), name='test list')
list2 = List(path=str(tmpdir), name='test list')
list3 = List(path=str(tmpdir), name='yet another test list')
assert list1 == list2
assert list1 != list3
assert list1 != 'test list'
def test_list_equality(tmpdir):
list1 = List(path=str(tmpdir), name='test list')
list2 = List(path=str(tmpdir), name='test list')
list3 = List(path=str(tmpdir), name='yet another test list')
assert list1 == list2
assert list1 != list3
assert list1 != 'test list'
def lists(self):
result = self._conn.execute("SELECT * FROM lists")
for row in result:
yield List(
name=row['name'],
path=row['path'],
colour=row['colour'],
)
def update_cache(self):
self.cache.expire_lists(self.paths)
paths_to_mtime = {}
paths_to_list_name = {}
for path in self.paths:
list_name = self.cache.add_list(
List.name_for_path(path),
path,
List.colour_for_path(path),
)
for entry in os.listdir(path):
if not entry.endswith('.ics'):
continue
entry_path = os.path.join(path, entry)
mtime = _getmtime(entry_path)
paths_to_mtime[entry_path] = mtime
paths_to_list_name[entry_path] = list_name
self.cache.expire_files(paths_to_mtime)
for entry_path, mtime in paths_to_mtime.items():
list_name = paths_to_list_name[entry_path]
try:
self.cache.add_file(list_name, entry_path, mtime)
def __eq__(self, other):
if isinstance(other, List):
return self.name == other.name
return object.__eq__(self, other)
def update_cache(self):
self.cache.expire_lists(self.paths)
paths_to_mtime = {}
paths_to_list_name = {}
for path in self.paths:
list_name = self.cache.add_list(
List.name_for_path(path),
path,
List.colour_for_path(path),
)
for entry in os.listdir(path):
if not entry.endswith('.ics'):
continue
entry_path = os.path.join(path, entry)
mtime = _getmtime(entry_path)
paths_to_mtime[entry_path] = mtime
paths_to_list_name[entry_path] = list_name
self.cache.expire_files(paths_to_mtime)
for entry_path, mtime in paths_to_mtime.items():
list_name = paths_to_list_name[entry_path]