Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.log.info("Running circleguard with check %r", c)
c.load(self.loader)
# comparer investigations
if detect & (Detect.STEAL_SIM | Detect.STEAL_CORR):
replays1 = c.all_replays1()
replays2 = c.all_replays2()
comparer = Comparer(replays1, replays2, detect)
yield from comparer.compare()
# investigator investigations
if detect & (Detect.RELAX | Detect.CORRECTION | Detect.TIMEWARP):
if detect & Detect.RELAX:
if not self.library:
# connect to library since it's a temporary one
library = Library(self.slider_dir.name)
else:
library = self.library
for replay in c.all_replays():
bm = None
# don't download beatmap unless we need it for relax
if detect & Detect.RELAX:
bm = library.lookup_by_id(replay.map_id, download=True, save=True)
investigator = Investigator(replay, detect, max_angle, min_distance, beatmap=bm)
yield from investigator.investigate()
if detect & Detect.RELAX:
if not self.library:
# disconnect from temporary library
library.close()
if db_path is not None:
# resolve relative paths
db_path = Path(db_path).absolute()
# they can set cache to False later with:func:`~.circleguard.set_options`
# if they want; assume caching is desired if db path is passed
self.cacher = Cacher(self.cache, db_path)
self.log = logging.getLogger(__name__)
# allow for people to pass their own loader implementation/subclass
self.loader = Loader(key, cacher=self.cacher) if loader is None else loader(key, self.cacher)
if slider_dir is None:
# have to keep a reference to it or the folder gets deleted and can't be walked by Library
self.slider_dir = TemporaryDirectory()
self.library = None
else:
self.library = Library(slider_dir)
self.events = events
self.painter = QPainter()
self.scale = 1
self.x_offset = 0
self.y_offset = 0
# beatmap init stuff
self.hitobjs = []
if beatmap_info.path:
self.beatmap = Beatmap.from_path(beatmap_info.path)
self.playback_len = self.get_hit_endtime(self.beatmap.hit_objects[-1])
elif beatmap_info.map_id:
self.beatmap = Library(get_setting("cache_dir")).lookup_by_id(beatmap_info.map_id, download=True, save=True)
self.playback_len = self.get_hit_endtime(self.beatmap.hit_objects[-1])
else:
self.playback_len = 0
self.has_beatmap = beatmap_info.available()
# TODO inelegant way to handle this, maybe rename some variables at the least
if not get_setting("render_beatmap"):
self.has_beatmap = False
# beatmap stuff
if self.has_beatmap:
# values taken from https://github.com/ppy/osu-wiki/blob/master/meta/unused/difficulty-settings.md
# but it was taken from the osu! wiki since then so this might be a bit incorrect.
if self.beatmap.approach_rate == 5:
self.preempt = 1200
elif self.beatmap.approach_rate < 5:
def library(beatmaps, recurse, progress):
"""Create a slider database from a directory of beatmaps.
"""
Library.create_db(beatmaps, recurse=recurse, show_progress=progress)
def __init__(self):
QFrame.__init__(self)
SingleLinkableSetting.__init__(self, "api_key")
self.library = Library(get_setting("cache_dir"))
self.loadables_combobox = QComboBox(self)
self.loadables_combobox.setInsertPolicy(QComboBox.NoInsert)
for loadable in MainTab.LOADABLES_COMBOBOX_REGISTRY:
self.loadables_combobox.addItem(loadable, loadable)
self.loadables_combobox.activated.connect(self.add_loadable)
self.checks_combobox = QComboBox(self)
self.checks_combobox.setInsertPolicy(QComboBox.NoInsert)
for check in MainTab.CHECKS_COMBOBOX_REGISTRY:
self.checks_combobox.addItem(check, check)
self.checks_combobox.activated.connect(self.add_check)
self.loadables_scrollarea = QScrollArea(self)
self.loadables_scrollarea.setWidget(ScrollableLoadablesWidget())
self.loadables_scrollarea.setWidgetResizable(True)