Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
values = {
**kwargs,
'path': path,
'alias_type': alias_type.value
}
if len(spec) > 1:
values['template'] = spec[1]
record = model.PathAlias.get(path=path)
if record:
record.set(**values)
else:
record = model.PathAlias(**values)
orm.commit()
return record
def postprocess(self, target):
""" Save objects in db.
:return value: A generated value
"""
if self.params.get('commit'):
commit()
return target
libVersion = installFromLocal()
if libVersion is None:
logger.error(" we couldn't install the version you specified.")
return None
libVersion.fromGit = True
libVersion.origin = option["url"]
libVersion.library.url = option["url"]
libVersion.library.default = not(option["no_defaults"])
if option["version"] != "":
libVersion.sha = REPO.head.commit.hexsha
commit()
return libVersion
except Exception as e:
logger.error(e)
logger.error("There was an error when installing the library. May you want to run init?")
return None
os.path.join(ensure_unicode(torrents_dir, 'utf-8'), ensure_unicode(f, 'utf-8')), 'utf-8'
)
if os.path.isfile(filepath) and ensure_unicode(f, 'utf-8').endswith(u'.torrent'):
torrents_list.append(filepath)
for chunk in chunks(torrents_list, 100): # 100 is a reasonable chunk size for commits
for f in chunk:
try:
self.add_torrent_to_channel(TorrentDef.load(f))
except DuplicateTorrentFileError:
pass
except Exception:
# Have to use the broad exception clause because Py3 versions of libtorrent
# generate generic Exceptions
errors_list.append(f)
orm.commit() # Optimization to drop excess cache
return torrents_list, errors_list
)
if libVersion is None:
libVersion = LibraryVersion( library=library
, name=version.name
, fromIndex=True
)
if version.joinpath("sha1").exists():
libVersion.sha = version.joinpath("sha1").read_text()
libVersion.origin = url
libVersion.fromGit = True
else:
logger.error(version.name + " no valid!.")
libVersion.delete()
commit()
# With all libraries indexed, we proceed to create the dependencies
# as objects for the index.
for lib in src.glob("*"):
library = Library.get(name = lib.name)
for version in library.getSortedVersions():
# click.echo(version.freezeName)
info = version.readInfoFromLibFile()
version.depend.clear()
for depend in info.get("depend", []):
if type(depend) == list:
logger.info("no supported yet but the format is X.X <= name <= Y.Y")
def delete(self, id):
'''Delete a person.'''
try:
person = Person[id]
except orm.ObjectNotFound:
abort(404)
person.delete()
orm.commit()
return jsonify({"message": "Successfully deleted person.",
"id": id}), 200
user = User.get(id=user_id)
if not user:
category = self.get_argument('category', 'all')
return self.render("user/message_box.html",
category=category, page=page)
message_box = current_user.get_message_box(user=user)
if not message_box:
result = {"status": "error", "message": "无此私信"}
return self.send_result(result)
form = MessageForm()
self.render("user/message.html", user=user, message_box=message_box,
form=form, page=page)
if message_box.status == 0:
message_box.status = 1
try:
orm.commit()
except:
pass
def remove_alias(path: str):
""" Remove a path alias.
Arguments:
path -- the path to remove the alias of
"""
orm.delete(p for p in model.PathAlias if p.path == path) # type:ignore
orm.commit()
def remove_by_path(fullpath: str, entry_id: int):
""" Remove entries for a path that don't match the expected ID """
orm.delete(pa for pa in model.PathAlias # type:ignore
if pa.entry.file_path == fullpath
and pa.entry.id != entry_id)
orm.delete(e for e in model.Entry # type:ignore
if e.file_path == fullpath
and e.id != entry_id)
orm.commit()
def add_tweet(tweet, sentiment):
text = tweet.text.translate(non_bmp_map)
tweet = Tweet(tweet_id=str(tweet.id), text=text, sentiment=sentiment)
orm.commit()