text
stringlengths
0
828
the given region+item combo.
:param int region_id: The region ID.
:param int type_id: The item's type ID.
:param datetime.datetime generated_at: The time that the order set
was generated.
:keyword bool error_if_orders_present: If True, raise an exception if
an order already exists for this item+region combo when this is
called. This failsafe may be disabled by passing False here.
""""""
key = '%s_%s' % (region_id, type_id)
if error_if_orders_present and self._orders.has_key(key):
raise ItemAlreadyPresentError(
""Orders already exist for the given region and type ID. ""
""Pass error_if_orders_present=False to disable this failsafe, ""
""if desired.""
)
self._orders[key] = MarketItemsInRegionList(
region_id, type_id, generated_at)"
1473,"def add_entry(self, entry):
""""""
Adds a MarketHistoryEntry instance to the list of market history entries
contained within this instance. Does some behind-the-scenes magic to
get it all ready for serialization.
:param MarketHistoryEntry entry: The history entry to add to
instance.
""""""
# This key is used to group the orders based on region.
key = '%s_%s' % (entry.region_id, entry.type_id)
if not self._history.has_key(key):
# We don't have any orders for this yet. Prep the region+item
# combo by instantiating a new MarketItemsInRegionList for
# the MarketOrders.
self.set_empty_region(
entry.region_id,
entry.type_id,
entry.generated_at
)
# The MarketOrder gets stuffed into the MarketItemsInRegionList for this
# item+region combo.
self._history[key].add_entry(entry)"
1474,"def set_empty_region(self, region_id, type_id, generated_at,
error_if_entries_present=True):
""""""
Prepares for the given region+item combo by instantiating a
:py:class:`HistoryItemsInRegionList` instance, which will track
region ID, type ID, and generated time. This is mostly used for
the JSON deserialization process in case there are no orders for
the given region+item combo.
:param int region_id: The region ID.
:param int type_id: The item's type ID.
:param datetime.datetime generated_at: The time that the order set
was generated.
:keyword bool error_if_entries_present: If True, raise an exception if
an entry already exists for this item+region combo when this is
called. This failsafe may be disabled by passing False here.
""""""
key = '%s_%s' % (region_id, type_id)
if error_if_entries_present and self._history.has_key(key):
raise ItemAlreadyPresentError(
""Orders already exist for the given region and type ID. ""
""Pass error_if_orders_present=False to disable this failsafe, ""
""if desired.""
)
self._history[key] = HistoryItemsInRegionList(
region_id, type_id, generated_at)"
1475,"def _find_file(self, file_name: str, lookup_dir: Path) -> Path or None:
'''Find a file in a directory by name. Check subdirectories recursively.
:param file_name: Name of the file
:lookup_dir: Starting directory
:returns: Path to the found file or None if the file was not found
:raises: FileNotFoundError
'''
self.logger.debug('Trying to find the file {file_name} inside the directory {lookup_dir}')
result = None
for item in lookup_dir.rglob('*'):
if item.name == file_name:
result = item
break
else:
raise FileNotFoundError(file_name)
self.logger.debug('File found: {result}')
return result"
1476,"def _sync_repo(self, repo_url: str, revision: str or None = None) -> Path:
'''Clone a Git repository to the cache dir. If it has been cloned before, update it.
:param repo_url: Repository URL
:param revision: Revision: branch, commit hash, or tag