mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-04-25 20:41:19 -05:00
Remove symlinks in local/ (these would break PluginDownloader)
This commit is contained in:
parent
08d3f675c5
commit
6424b3664f
@ -1 +0,0 @@
|
||||
../../accountsdb.py
|
64
LastFM/local/accountsdb.py
Normal file
64
LastFM/local/accountsdb.py
Normal file
@ -0,0 +1,64 @@
|
||||
# Autogenerated by update-modules.py on Sun Dec 30 13:09:36 2018 - DO NOT EDIT THIS COPY DIRECTLY!
|
||||
"""
|
||||
Shared code for database handling.
|
||||
"""
|
||||
|
||||
import pickle
|
||||
|
||||
from supybot import ircdb, log
|
||||
|
||||
class AccountsDB():
|
||||
"""
|
||||
Abstraction to map users to third-party account names.
|
||||
|
||||
This stores users by their bot account first, falling back to their
|
||||
ident@host if they are not logged in.
|
||||
"""
|
||||
|
||||
def __init__(self, plugin_name, filename):
|
||||
"""
|
||||
Loads the existing database, creating a new one in memory if none
|
||||
exists.
|
||||
"""
|
||||
self.db = {}
|
||||
self._plugin_name = plugin_name
|
||||
self.filename = filename
|
||||
try:
|
||||
with open(self.filename, 'rb') as f:
|
||||
self.db = pickle.load(f)
|
||||
except Exception as e:
|
||||
log.debug('%s: Unable to load database, creating '
|
||||
'a new one: %s', self._plugin_name, e)
|
||||
|
||||
def flush(self):
|
||||
"""Exports the database to a file."""
|
||||
try:
|
||||
with open(self.filename, 'wb') as f:
|
||||
pickle.dump(self.db, f, 2)
|
||||
except Exception as e:
|
||||
log.warning('%s: Unable to write database: %s', self._plugin_name, e)
|
||||
|
||||
def set(self, prefix, newId):
|
||||
"""Sets a user ID given the user's prefix."""
|
||||
|
||||
try: # Try to first look up the caller as a bot account.
|
||||
userobj = ircdb.users.getUser(prefix)
|
||||
except KeyError: # If that fails, store them by nick@host.
|
||||
user = prefix.split('!', 1)[1]
|
||||
else:
|
||||
user = userobj.name
|
||||
|
||||
self.db[user] = newId
|
||||
|
||||
def get(self, prefix):
|
||||
"""Sets a user ID given the user's prefix."""
|
||||
|
||||
try: # Try to first look up the caller as a bot account.
|
||||
userobj = ircdb.users.getUser(prefix)
|
||||
except KeyError: # If that fails, store them by nick@host.
|
||||
user = prefix.split('!', 1)[1]
|
||||
else:
|
||||
user = userobj.name
|
||||
|
||||
# Automatically returns None if entry does not exist
|
||||
return self.db.get(user)
|
@ -1 +0,0 @@
|
||||
../../accountsdb.py
|
64
NuWeather/local/accountsdb.py
Normal file
64
NuWeather/local/accountsdb.py
Normal file
@ -0,0 +1,64 @@
|
||||
# Autogenerated by update-modules.py on Sun Dec 30 13:09:36 2018 - DO NOT EDIT THIS COPY DIRECTLY!
|
||||
"""
|
||||
Shared code for database handling.
|
||||
"""
|
||||
|
||||
import pickle
|
||||
|
||||
from supybot import ircdb, log
|
||||
|
||||
class AccountsDB():
|
||||
"""
|
||||
Abstraction to map users to third-party account names.
|
||||
|
||||
This stores users by their bot account first, falling back to their
|
||||
ident@host if they are not logged in.
|
||||
"""
|
||||
|
||||
def __init__(self, plugin_name, filename):
|
||||
"""
|
||||
Loads the existing database, creating a new one in memory if none
|
||||
exists.
|
||||
"""
|
||||
self.db = {}
|
||||
self._plugin_name = plugin_name
|
||||
self.filename = filename
|
||||
try:
|
||||
with open(self.filename, 'rb') as f:
|
||||
self.db = pickle.load(f)
|
||||
except Exception as e:
|
||||
log.debug('%s: Unable to load database, creating '
|
||||
'a new one: %s', self._plugin_name, e)
|
||||
|
||||
def flush(self):
|
||||
"""Exports the database to a file."""
|
||||
try:
|
||||
with open(self.filename, 'wb') as f:
|
||||
pickle.dump(self.db, f, 2)
|
||||
except Exception as e:
|
||||
log.warning('%s: Unable to write database: %s', self._plugin_name, e)
|
||||
|
||||
def set(self, prefix, newId):
|
||||
"""Sets a user ID given the user's prefix."""
|
||||
|
||||
try: # Try to first look up the caller as a bot account.
|
||||
userobj = ircdb.users.getUser(prefix)
|
||||
except KeyError: # If that fails, store them by nick@host.
|
||||
user = prefix.split('!', 1)[1]
|
||||
else:
|
||||
user = userobj.name
|
||||
|
||||
self.db[user] = newId
|
||||
|
||||
def get(self, prefix):
|
||||
"""Sets a user ID given the user's prefix."""
|
||||
|
||||
try: # Try to first look up the caller as a bot account.
|
||||
userobj = ircdb.users.getUser(prefix)
|
||||
except KeyError: # If that fails, store them by nick@host.
|
||||
user = prefix.split('!', 1)[1]
|
||||
else:
|
||||
user = userobj.name
|
||||
|
||||
# Automatically returns None if entry does not exist
|
||||
return self.db.get(user)
|
20
update-modules.py
Executable file
20
update-modules.py
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
# Refresh shared modules so that PluginDownloader downloads don't break.
|
||||
|
||||
CONFIG = {'accountsdb.py': ('LastFM/local', 'NuWeather/local')}
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
for filename, paths in CONFIG.items():
|
||||
with open(filename) as f:
|
||||
data = f.read()
|
||||
for path in paths:
|
||||
target = os.path.join(path, filename)
|
||||
if os.path.exists(target):
|
||||
print("Deleting existing %s" % target)
|
||||
os.remove(target)
|
||||
print("Writing %s => %s" % (filename, target))
|
||||
with open(target, 'w') as wf:
|
||||
wf.write('# Autogenerated by update-modules.py on %s - DO NOT EDIT THIS COPY DIRECTLY!\n' % time.ctime())
|
||||
wf.write(data)
|
Loading…
x
Reference in New Issue
Block a user