Skip to content

Commit

Permalink
fix: Fix 88a4e45, which changed default version to None instead of ''…
Browse files Browse the repository at this point in the history
… for consistency
  • Loading branch information
jpmckinney committed Jul 18, 2024
1 parent 54e4ace commit 413bfe4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scrapyd/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def __len__(self):
def __iter__(self):
yield from self.iterkeys()

def __repr__(self):
return f"JsonSqliteDict({dict(self.iteritems())})"

def iterkeys(self):
sql = f"SELECT key FROM {self.table}"
return (self.decode(row[0]) for row in self.conn.execute(sql))
Expand Down
9 changes: 9 additions & 0 deletions scrapyd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def __getitem__(self, key):
def __setitem__(self, key, value):
self.cache_manager[key] = value

def __repr__(self):
return f"UtilsCache(cache_manager={self.cache_manager!r})"


def get_spider_queues(config):
"""Return a dict of Spider Queues keyed by project name"""
Expand Down Expand Up @@ -125,6 +128,12 @@ def get_crawl_args(message):

def get_spider_list(project, runner=None, pythonpath=None, version=None):
"""Return the spider list from the given project, using the given runner"""

# UtilsCache uses JsonSqliteDict, which encodes the project's value as JSON, but JSON allows only string keys,
# so the stored dict will have a "null" key, instead of a None key.
if version is None:
version = ""

if "cache" not in get_spider_list.__dict__:
get_spider_list.cache = UtilsCache()
try:
Expand Down

0 comments on commit 413bfe4

Please sign in to comment.