def setUp(self): config.clear() config.read(user=False) self.importfeeds = ImportFeedsPlugin() self.lib = Library(':memory:') self.feeds_dir = tempfile.mkdtemp() config['importfeeds']['dir'] = self.feeds_dir
def prompt_tags(db_file, query): library = Library(db_file) for track in library.items(query=query): try: scan_version = int(float(track.scan_version)) except Exception: scan_version = 0 if scan_version < VERSION: _prompt_for_track(track, TAGS_MODEL) track.scan_version = VERSION track.store()
def test_edit_invalid_config_file(self): self.lib = Library(':memory:') with open(self.config_path, 'w') as file: file.write('invalid: [') config.clear() config._materialized = False os.environ['EDITOR'] = 'myeditor' with patch('os.execlp') as execlp: self.run_command('config', '-e') execlp.assert_called_once_with('myeditor', 'myeditor', self.config_path)
def get_tracks(db_file, tag_list: List[str]) -> Dict[str, Track]: result = dict() library = Library(db_file) tag_list = [ tag for tag in tag_list if tag != "rating" and not tag.startswith("_") ] for item in library.items(): path = convert_attr_to_string(item.path).lower() tags = {tag: _get_attr_dont_throw(item, tag) for tag in tag_list} rating = _get_int_attr_dont_throw(item, "rating") if not (rating is not None and 0 <= rating <= 5): rating = None result[path] = Track(Path(path), tags, rating) return result
def setup_beets(self, disk=False): """Setup pristine global configuration and library for testing. Sets ``beets.config`` so we can safely use any functionality that uses the global configuration. All paths used are contained in a temporary directory Sets the following properties on itself. - ``temp_dir`` Path to a temporary directory containing all files specific to beets - ``libdir`` Path to a subfolder of ``temp_dir``, containing the library's media files. Same as ``config['directory']``. - ``config`` The global configuration used by beets. - ``lib`` Library instance created with the settings from ``config``. Make sure you call ``teardown_beets()`` afterwards. """ self.create_temp_dir() os.environ['BEETSDIR'] = util.py3_path(self.temp_dir) self.config = beets.config self.config.clear() self.config.read() self.config['plugins'] = [] self.config['verbose'] = 1 self.config['ui']['color'] = False self.config['threaded'] = False self.libdir = os.path.join(self.temp_dir, b'libdir') os.mkdir(self.libdir) self.config['directory'] = util.py3_path(self.libdir) if disk: dbpath = util.bytestring_path( self.config['library'].as_filename() ) else: dbpath = ':memory:' self.lib = Library(dbpath, self.libdir)
def setUp(self): self.lib = Library(':memory:') self.temp_dir = mkdtemp() if 'EDITOR' in os.environ: del os.environ['EDITOR'] os.environ['BEETSDIR'] = self.temp_dir self.config_path = os.path.join(self.temp_dir, 'config.yaml') with open(self.config_path, 'w') as file: file.write('library: lib\n') file.write('option: value\n') file.write('password: password_value') self.cli_config_path = os.path.join(self.temp_dir, 'cli_config.yaml') with open(self.cli_config_path, 'w') as file: file.write('option: cli overwrite') config.clear() config['password'].redact = True config._materialized = False
def write_tracks_rating_and_tags(db_file, tracks: Dict[str, Track]): library = Library(db_file) conflicting_tracks = [] traktor_modification_count = 0 for i in library.items(): path = convert_attr_to_string(i.path).lower() if path in tracks: if tracks.get(path).rating is not None: i.rating = tracks.get(path).rating conflicting_tags = [] for tag_key, traktor_tag_value in tracks.get(path).tags.items(): existing_tag_in_beets = _get_attr_dont_throw(i, tag_key) if existing_tag_in_beets is None or existing_tag_in_beets != traktor_tag_value: traktor_modification_count += 1 setattr(i, tag_key, traktor_tag_value) if existing_tag_in_beets is not None and existing_tag_in_beets != traktor_tag_value: conflicting_tags.append( (tag_key, existing_tag_in_beets, traktor_tag_value)) if conflicting_tags: conflicting_tracks.append((path, conflicting_tags)) i.store() if conflicting_tracks: for c in conflicting_tracks[:10]: print( "Conflict in '%s':\n Conflicting tags (tag_key, beet_tags, traktor_tags):\n\t%s" % (c[0], c[1])) print("==========================") print( "Conflicting tags were overwritten in beets: Traktor tags have priority over beets" ) print("Total conflicting tracks: %s" % len(conflicting_tracks)) print("New tags coming from Traktor: %s" % traktor_modification_count)
def setUp(self): self.lib = Library(':memory:')
def setUp(self): self.lib = Library(':memory:') Item._types = {'flexbool': types.Boolean()}
def run_command(self, *args): if hasattr(self, 'lib'): lib = self.lib else: lib = Library(':memory:') beets.ui._raw_main(list(args), lib)
def beets_init(path): return Library(path)
gitAnnexLib.from_backup(beetsCommands.get_library()) return redirect('/albums') @app.route("/artists") def artysci(): return render_template('artists.html') @app.route("/songs") def muzyka(): return render_template('songs.html') local_repo = gitAnnexLib.Repo(path=beetsCommands.get_library(), local=1) lib = Library(beetsCommands.get_database()) local_repo.annex_direct() get_backup(local_repo.path) import_to_beets(local_repo.path, first=1) get_backup(local_repo.path) local_repo.annex_indirect() #print("local repo autopushing sdsdfsdfdsfdsfsdfs") #print(local_repo.autopushing) for autopush in local_repo.autopushing: autopush.get_from(local_repo) #print("local repo autogetting sdsdfsdfdsfdsfsdfs") #print(local_repo.autogetting) for autoget in local_repo.autogetting: local_repo.get_from(autoget) if __name__ == "__main__":