prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>331.py<|end_file_name|><|fim▁begin|>class Solution: def <|fim_middle|>(self, preorder): """ :type preorder: str :rtype: bool """ arr_pre_order = preorder.split(',') stack = [] for node in arr_pre_order: stack.append(node) while len(stack) > 1 and stack[-1] == '#' and stack[-2] == '#': stack.pop() stack.pop() if len(stack) < 1: return False stack[-1] = '#' if len(stack) == 1 and stack[0] == '#': return True return False <|fim▁end|>
isValidSerialization
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip()<|fim▁hole|>def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall<|fim▁end|>
self.root = ET.fromstring(s) print(root)
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): <|fim_middle|> class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
for x in msgs: print('[WARNING]:', x, file=sys.stderr)
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: <|fim_middle|> def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root)
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() <|fim_middle|> def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root)
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): <|fim_middle|> f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
s = '' for x in l: s += x.rstrip() + '\n' return s
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): <|fim_middle|> def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close()
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): <|fim_middle|> if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close()
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): <|fim_middle|> print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
prefix += '/'
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: <|fim_middle|> if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
header += l firstline -= 1 continue
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: <|fim_middle|> if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
continue
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): <|fim_middle|> if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
continue
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): <|fim_middle|> entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header)
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): <|fim_middle|> if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
prefix += '/'
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): <|fim_middle|> for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
os.mkdir(prefix)
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': <|fim_middle|> <|fim▁end|>
parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: <|fim_middle|> else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
build_database(args.db, args.directory)
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) <|fim_middle|> #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory)
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): <|fim_middle|> if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
os.mkdir(args.directory)
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): <|fim_middle|> build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
get_database(args.directory)
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def <|fim_middle|>(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
warn
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def <|fim_middle|>(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
__init__
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def <|fim_middle|>(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
strsum
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def <|fim_middle|>(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def build_database(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
get_database
<|file_name|>dbtool.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2 from __future__ import print_function import sys import os import urllib import argparse import xml.etree.ElementTree as ET def warn(*msgs): for x in msgs: print('[WARNING]:', x, file=sys.stderr) class PDBTM: def __init__(self, filename): #self.tree = ET.parse(filename) #self.root = self.tree.getroot() def strsum(l): s = '' for x in l: s += x.rstrip() + '\n' return s f = open(filename) s = [] for l in f: s.append(l) #s = strsum(s[1:-1]).strip() s = strsum(s).strip() self.root = ET.fromstring(s) print(root) def get_database(prefix='.'): if not prefix.endswith('/'): prefix += '/' print('Fetching database...', file=sys.stderr) db = urllib.urlopen('http://pdbtm.enzim.hu/data/pdbtmall') print('Saving database...', file=sys.stderr) f = open('%s/pdbtmall' % prefix, 'w') for l in db: f.write(l) #f.write(db.read()) db.close() f.close() def <|fim_middle|>(fn, prefix): print('Unpacking database...', file=sys.stderr) f = open(fn) db = f.read() f.close() firstline = 1 header = '' entries = [] pdbids = [] for l in db.split('\n'): if firstline: header += l firstline -= 1 continue if 'PDBTM>' in l: continue if l.startswith('<?'): continue if l.startswith('<pdbtm'): a = l.find('ID=') + 4 b = a + 4 pdbids.append(l[a:b]) entries.append(header) entries[-1] += '\n' + l if not prefix.endswith('/'): prefix += '/' if not os.path.isdir(prefix): os.mkdir(prefix) for entry in zip(pdbids, entries): f = open(prefix + entry[0] + '.xml', 'w') f.write(entry[1]) f.close() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Manages PDBTM databases. Automatically fetches the PDBTM database if no options are specified. Run without any arguments, dbtool will retrieve the PDBTM database, store it in pdbtm, and unpack it.') parser.add_argument('-d', '--db', default='pdbtmall', help='name of concatenated database file {default:pdbtmall}') parser.add_argument('-b', '--build-db', action='store_true', help='(re)build database from an existing pdbtmsall file (available at http://pdbtm.enzim.hu/data/pdbtmall)') parser.add_argument('directory', nargs='?', default='pdbtm', help='directory to store database in') parser.add_argument('-f', '--force-refresh', action='store_true', help='force overwrite of existing database. Functionally equivalent to removing the old database and rerunning.') #parser.add_argument('-n', metavar='bundle_size', type=int, help='size to cut bundles into') args = parser.parse_args() if args.build_db: build_database(args.db, args.directory) else: #db = PDBTM(args.db) if not os.path.isdir(args.directory): os.mkdir(args.directory) if args.force_refresh or not os.path.isfile('%s/%s' % (args.directory, args.db)): get_database(args.directory) build_database('%s/%s' % (args.directory, args.db), args.directory) #http://pdbtm.enzim.hu/data/pdbtmall <|fim▁end|>
build_database
<|file_name|>category_links.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from django import forms from django.utils.translation import ugettext_lazy as _ from shuup.core.models import Category from shuup.xtheme import TemplatedPlugin from shuup.xtheme.plugins.forms import GenericPluginForm, TranslatableField class CategoryLinksConfigForm(GenericPluginForm): """ A configuration form for the CategoryLinksPlugin """ def populate(self): """ A custom populate method to display category choices """ for field in self.plugin.fields: if isinstance(field, tuple): name, value = field value.initial = self.plugin.config.get(name, value.initial) self.fields[name] = value self.fields["categories"] = forms.ModelMultipleChoiceField( queryset=Category.objects.all_visible(customer=None), required=False, initial=self.plugin.config.get("categories", None), ) def clean(self): """ A custom clean method to save category configuration information in a serializable form """ cleaned_data = super(CategoryLinksConfigForm, self).clean() categories = cleaned_data.get("categories", []) cleaned_data["categories"] = [category.pk for category in categories if hasattr(category, "pk")] return cleaned_data class CategoryLinksPlugin(TemplatedPlugin): """ A plugin for displaying links to visible categories on the shop front """<|fim▁hole|> template_name = "shuup/xtheme/plugins/category_links.jinja" editor_form_class = CategoryLinksConfigForm fields = [ ("title", TranslatableField(label=_("Title"), required=False, initial="")), ("show_all_categories", forms.BooleanField( label=_("Show all categories"), required=False, initial=True, help_text=_("All categories are shown, even if not selected"), )), "categories", ] def get_context_data(self, context): """ A custom get_context_data method to return only visible categories for request customer. """ selected_categories = self.config.get("categories", []) show_all_categories = self.config.get("show_all_categories", True) request = context.get("request") categories = Category.objects.all_visible( customer=getattr(request, "customer"), shop=getattr(request, "shop") ) if not show_all_categories: categories = categories.filter(id__in=selected_categories) return { "title": self.get_translated_value("title"), "categories": categories, }<|fim▁end|>
identifier = "category_links" name = _("Category Links")
<|file_name|>category_links.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from django import forms from django.utils.translation import ugettext_lazy as _ from shuup.core.models import Category from shuup.xtheme import TemplatedPlugin from shuup.xtheme.plugins.forms import GenericPluginForm, TranslatableField class CategoryLinksConfigForm(GenericPluginForm): <|fim_middle|> class CategoryLinksPlugin(TemplatedPlugin): """ A plugin for displaying links to visible categories on the shop front """ identifier = "category_links" name = _("Category Links") template_name = "shuup/xtheme/plugins/category_links.jinja" editor_form_class = CategoryLinksConfigForm fields = [ ("title", TranslatableField(label=_("Title"), required=False, initial="")), ("show_all_categories", forms.BooleanField( label=_("Show all categories"), required=False, initial=True, help_text=_("All categories are shown, even if not selected"), )), "categories", ] def get_context_data(self, context): """ A custom get_context_data method to return only visible categories for request customer. """ selected_categories = self.config.get("categories", []) show_all_categories = self.config.get("show_all_categories", True) request = context.get("request") categories = Category.objects.all_visible( customer=getattr(request, "customer"), shop=getattr(request, "shop") ) if not show_all_categories: categories = categories.filter(id__in=selected_categories) return { "title": self.get_translated_value("title"), "categories": categories, } <|fim▁end|>
""" A configuration form for the CategoryLinksPlugin """ def populate(self): """ A custom populate method to display category choices """ for field in self.plugin.fields: if isinstance(field, tuple): name, value = field value.initial = self.plugin.config.get(name, value.initial) self.fields[name] = value self.fields["categories"] = forms.ModelMultipleChoiceField( queryset=Category.objects.all_visible(customer=None), required=False, initial=self.plugin.config.get("categories", None), ) def clean(self): """ A custom clean method to save category configuration information in a serializable form """ cleaned_data = super(CategoryLinksConfigForm, self).clean() categories = cleaned_data.get("categories", []) cleaned_data["categories"] = [category.pk for category in categories if hasattr(category, "pk")] return cleaned_data
<|file_name|>category_links.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from django import forms from django.utils.translation import ugettext_lazy as _ from shuup.core.models import Category from shuup.xtheme import TemplatedPlugin from shuup.xtheme.plugins.forms import GenericPluginForm, TranslatableField class CategoryLinksConfigForm(GenericPluginForm): """ A configuration form for the CategoryLinksPlugin """ def populate(self): <|fim_middle|> def clean(self): """ A custom clean method to save category configuration information in a serializable form """ cleaned_data = super(CategoryLinksConfigForm, self).clean() categories = cleaned_data.get("categories", []) cleaned_data["categories"] = [category.pk for category in categories if hasattr(category, "pk")] return cleaned_data class CategoryLinksPlugin(TemplatedPlugin): """ A plugin for displaying links to visible categories on the shop front """ identifier = "category_links" name = _("Category Links") template_name = "shuup/xtheme/plugins/category_links.jinja" editor_form_class = CategoryLinksConfigForm fields = [ ("title", TranslatableField(label=_("Title"), required=False, initial="")), ("show_all_categories", forms.BooleanField( label=_("Show all categories"), required=False, initial=True, help_text=_("All categories are shown, even if not selected"), )), "categories", ] def get_context_data(self, context): """ A custom get_context_data method to return only visible categories for request customer. """ selected_categories = self.config.get("categories", []) show_all_categories = self.config.get("show_all_categories", True) request = context.get("request") categories = Category.objects.all_visible( customer=getattr(request, "customer"), shop=getattr(request, "shop") ) if not show_all_categories: categories = categories.filter(id__in=selected_categories) return { "title": self.get_translated_value("title"), "categories": categories, } <|fim▁end|>
""" A custom populate method to display category choices """ for field in self.plugin.fields: if isinstance(field, tuple): name, value = field value.initial = self.plugin.config.get(name, value.initial) self.fields[name] = value self.fields["categories"] = forms.ModelMultipleChoiceField( queryset=Category.objects.all_visible(customer=None), required=False, initial=self.plugin.config.get("categories", None), )
<|file_name|>category_links.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from django import forms from django.utils.translation import ugettext_lazy as _ from shuup.core.models import Category from shuup.xtheme import TemplatedPlugin from shuup.xtheme.plugins.forms import GenericPluginForm, TranslatableField class CategoryLinksConfigForm(GenericPluginForm): """ A configuration form for the CategoryLinksPlugin """ def populate(self): """ A custom populate method to display category choices """ for field in self.plugin.fields: if isinstance(field, tuple): name, value = field value.initial = self.plugin.config.get(name, value.initial) self.fields[name] = value self.fields["categories"] = forms.ModelMultipleChoiceField( queryset=Category.objects.all_visible(customer=None), required=False, initial=self.plugin.config.get("categories", None), ) def clean(self): <|fim_middle|> class CategoryLinksPlugin(TemplatedPlugin): """ A plugin for displaying links to visible categories on the shop front """ identifier = "category_links" name = _("Category Links") template_name = "shuup/xtheme/plugins/category_links.jinja" editor_form_class = CategoryLinksConfigForm fields = [ ("title", TranslatableField(label=_("Title"), required=False, initial="")), ("show_all_categories", forms.BooleanField( label=_("Show all categories"), required=False, initial=True, help_text=_("All categories are shown, even if not selected"), )), "categories", ] def get_context_data(self, context): """ A custom get_context_data method to return only visible categories for request customer. """ selected_categories = self.config.get("categories", []) show_all_categories = self.config.get("show_all_categories", True) request = context.get("request") categories = Category.objects.all_visible( customer=getattr(request, "customer"), shop=getattr(request, "shop") ) if not show_all_categories: categories = categories.filter(id__in=selected_categories) return { "title": self.get_translated_value("title"), "categories": categories, } <|fim▁end|>
""" A custom clean method to save category configuration information in a serializable form """ cleaned_data = super(CategoryLinksConfigForm, self).clean() categories = cleaned_data.get("categories", []) cleaned_data["categories"] = [category.pk for category in categories if hasattr(category, "pk")] return cleaned_data
<|file_name|>category_links.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from django import forms from django.utils.translation import ugettext_lazy as _ from shuup.core.models import Category from shuup.xtheme import TemplatedPlugin from shuup.xtheme.plugins.forms import GenericPluginForm, TranslatableField class CategoryLinksConfigForm(GenericPluginForm): """ A configuration form for the CategoryLinksPlugin """ def populate(self): """ A custom populate method to display category choices """ for field in self.plugin.fields: if isinstance(field, tuple): name, value = field value.initial = self.plugin.config.get(name, value.initial) self.fields[name] = value self.fields["categories"] = forms.ModelMultipleChoiceField( queryset=Category.objects.all_visible(customer=None), required=False, initial=self.plugin.config.get("categories", None), ) def clean(self): """ A custom clean method to save category configuration information in a serializable form """ cleaned_data = super(CategoryLinksConfigForm, self).clean() categories = cleaned_data.get("categories", []) cleaned_data["categories"] = [category.pk for category in categories if hasattr(category, "pk")] return cleaned_data class CategoryLinksPlugin(TemplatedPlugin): <|fim_middle|> <|fim▁end|>
""" A plugin for displaying links to visible categories on the shop front """ identifier = "category_links" name = _("Category Links") template_name = "shuup/xtheme/plugins/category_links.jinja" editor_form_class = CategoryLinksConfigForm fields = [ ("title", TranslatableField(label=_("Title"), required=False, initial="")), ("show_all_categories", forms.BooleanField( label=_("Show all categories"), required=False, initial=True, help_text=_("All categories are shown, even if not selected"), )), "categories", ] def get_context_data(self, context): """ A custom get_context_data method to return only visible categories for request customer. """ selected_categories = self.config.get("categories", []) show_all_categories = self.config.get("show_all_categories", True) request = context.get("request") categories = Category.objects.all_visible( customer=getattr(request, "customer"), shop=getattr(request, "shop") ) if not show_all_categories: categories = categories.filter(id__in=selected_categories) return { "title": self.get_translated_value("title"), "categories": categories, }
<|file_name|>category_links.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from django import forms from django.utils.translation import ugettext_lazy as _ from shuup.core.models import Category from shuup.xtheme import TemplatedPlugin from shuup.xtheme.plugins.forms import GenericPluginForm, TranslatableField class CategoryLinksConfigForm(GenericPluginForm): """ A configuration form for the CategoryLinksPlugin """ def populate(self): """ A custom populate method to display category choices """ for field in self.plugin.fields: if isinstance(field, tuple): name, value = field value.initial = self.plugin.config.get(name, value.initial) self.fields[name] = value self.fields["categories"] = forms.ModelMultipleChoiceField( queryset=Category.objects.all_visible(customer=None), required=False, initial=self.plugin.config.get("categories", None), ) def clean(self): """ A custom clean method to save category configuration information in a serializable form """ cleaned_data = super(CategoryLinksConfigForm, self).clean() categories = cleaned_data.get("categories", []) cleaned_data["categories"] = [category.pk for category in categories if hasattr(category, "pk")] return cleaned_data class CategoryLinksPlugin(TemplatedPlugin): """ A plugin for displaying links to visible categories on the shop front """ identifier = "category_links" name = _("Category Links") template_name = "shuup/xtheme/plugins/category_links.jinja" editor_form_class = CategoryLinksConfigForm fields = [ ("title", TranslatableField(label=_("Title"), required=False, initial="")), ("show_all_categories", forms.BooleanField( label=_("Show all categories"), required=False, initial=True, help_text=_("All categories are shown, even if not selected"), )), "categories", ] def get_context_data(self, context): <|fim_middle|> <|fim▁end|>
""" A custom get_context_data method to return only visible categories for request customer. """ selected_categories = self.config.get("categories", []) show_all_categories = self.config.get("show_all_categories", True) request = context.get("request") categories = Category.objects.all_visible( customer=getattr(request, "customer"), shop=getattr(request, "shop") ) if not show_all_categories: categories = categories.filter(id__in=selected_categories) return { "title": self.get_translated_value("title"), "categories": categories, }
<|file_name|>category_links.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from django import forms from django.utils.translation import ugettext_lazy as _ from shuup.core.models import Category from shuup.xtheme import TemplatedPlugin from shuup.xtheme.plugins.forms import GenericPluginForm, TranslatableField class CategoryLinksConfigForm(GenericPluginForm): """ A configuration form for the CategoryLinksPlugin """ def populate(self): """ A custom populate method to display category choices """ for field in self.plugin.fields: if isinstance(field, tuple): <|fim_middle|> self.fields["categories"] = forms.ModelMultipleChoiceField( queryset=Category.objects.all_visible(customer=None), required=False, initial=self.plugin.config.get("categories", None), ) def clean(self): """ A custom clean method to save category configuration information in a serializable form """ cleaned_data = super(CategoryLinksConfigForm, self).clean() categories = cleaned_data.get("categories", []) cleaned_data["categories"] = [category.pk for category in categories if hasattr(category, "pk")] return cleaned_data class CategoryLinksPlugin(TemplatedPlugin): """ A plugin for displaying links to visible categories on the shop front """ identifier = "category_links" name = _("Category Links") template_name = "shuup/xtheme/plugins/category_links.jinja" editor_form_class = CategoryLinksConfigForm fields = [ ("title", TranslatableField(label=_("Title"), required=False, initial="")), ("show_all_categories", forms.BooleanField( label=_("Show all categories"), required=False, initial=True, help_text=_("All categories are shown, even if not selected"), )), "categories", ] def get_context_data(self, context): """ A custom get_context_data method to return only visible categories for request customer. """ selected_categories = self.config.get("categories", []) show_all_categories = self.config.get("show_all_categories", True) request = context.get("request") categories = Category.objects.all_visible( customer=getattr(request, "customer"), shop=getattr(request, "shop") ) if not show_all_categories: categories = categories.filter(id__in=selected_categories) return { "title": self.get_translated_value("title"), "categories": categories, } <|fim▁end|>
name, value = field value.initial = self.plugin.config.get(name, value.initial) self.fields[name] = value
<|file_name|>category_links.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from django import forms from django.utils.translation import ugettext_lazy as _ from shuup.core.models import Category from shuup.xtheme import TemplatedPlugin from shuup.xtheme.plugins.forms import GenericPluginForm, TranslatableField class CategoryLinksConfigForm(GenericPluginForm): """ A configuration form for the CategoryLinksPlugin """ def populate(self): """ A custom populate method to display category choices """ for field in self.plugin.fields: if isinstance(field, tuple): name, value = field value.initial = self.plugin.config.get(name, value.initial) self.fields[name] = value self.fields["categories"] = forms.ModelMultipleChoiceField( queryset=Category.objects.all_visible(customer=None), required=False, initial=self.plugin.config.get("categories", None), ) def clean(self): """ A custom clean method to save category configuration information in a serializable form """ cleaned_data = super(CategoryLinksConfigForm, self).clean() categories = cleaned_data.get("categories", []) cleaned_data["categories"] = [category.pk for category in categories if hasattr(category, "pk")] return cleaned_data class CategoryLinksPlugin(TemplatedPlugin): """ A plugin for displaying links to visible categories on the shop front """ identifier = "category_links" name = _("Category Links") template_name = "shuup/xtheme/plugins/category_links.jinja" editor_form_class = CategoryLinksConfigForm fields = [ ("title", TranslatableField(label=_("Title"), required=False, initial="")), ("show_all_categories", forms.BooleanField( label=_("Show all categories"), required=False, initial=True, help_text=_("All categories are shown, even if not selected"), )), "categories", ] def get_context_data(self, context): """ A custom get_context_data method to return only visible categories for request customer. """ selected_categories = self.config.get("categories", []) show_all_categories = self.config.get("show_all_categories", True) request = context.get("request") categories = Category.objects.all_visible( customer=getattr(request, "customer"), shop=getattr(request, "shop") ) if not show_all_categories: <|fim_middle|> return { "title": self.get_translated_value("title"), "categories": categories, } <|fim▁end|>
categories = categories.filter(id__in=selected_categories)
<|file_name|>category_links.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from django import forms from django.utils.translation import ugettext_lazy as _ from shuup.core.models import Category from shuup.xtheme import TemplatedPlugin from shuup.xtheme.plugins.forms import GenericPluginForm, TranslatableField class CategoryLinksConfigForm(GenericPluginForm): """ A configuration form for the CategoryLinksPlugin """ def <|fim_middle|>(self): """ A custom populate method to display category choices """ for field in self.plugin.fields: if isinstance(field, tuple): name, value = field value.initial = self.plugin.config.get(name, value.initial) self.fields[name] = value self.fields["categories"] = forms.ModelMultipleChoiceField( queryset=Category.objects.all_visible(customer=None), required=False, initial=self.plugin.config.get("categories", None), ) def clean(self): """ A custom clean method to save category configuration information in a serializable form """ cleaned_data = super(CategoryLinksConfigForm, self).clean() categories = cleaned_data.get("categories", []) cleaned_data["categories"] = [category.pk for category in categories if hasattr(category, "pk")] return cleaned_data class CategoryLinksPlugin(TemplatedPlugin): """ A plugin for displaying links to visible categories on the shop front """ identifier = "category_links" name = _("Category Links") template_name = "shuup/xtheme/plugins/category_links.jinja" editor_form_class = CategoryLinksConfigForm fields = [ ("title", TranslatableField(label=_("Title"), required=False, initial="")), ("show_all_categories", forms.BooleanField( label=_("Show all categories"), required=False, initial=True, help_text=_("All categories are shown, even if not selected"), )), "categories", ] def get_context_data(self, context): """ A custom get_context_data method to return only visible categories for request customer. """ selected_categories = self.config.get("categories", []) show_all_categories = self.config.get("show_all_categories", True) request = context.get("request") categories = Category.objects.all_visible( customer=getattr(request, "customer"), shop=getattr(request, "shop") ) if not show_all_categories: categories = categories.filter(id__in=selected_categories) return { "title": self.get_translated_value("title"), "categories": categories, } <|fim▁end|>
populate
<|file_name|>category_links.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from django import forms from django.utils.translation import ugettext_lazy as _ from shuup.core.models import Category from shuup.xtheme import TemplatedPlugin from shuup.xtheme.plugins.forms import GenericPluginForm, TranslatableField class CategoryLinksConfigForm(GenericPluginForm): """ A configuration form for the CategoryLinksPlugin """ def populate(self): """ A custom populate method to display category choices """ for field in self.plugin.fields: if isinstance(field, tuple): name, value = field value.initial = self.plugin.config.get(name, value.initial) self.fields[name] = value self.fields["categories"] = forms.ModelMultipleChoiceField( queryset=Category.objects.all_visible(customer=None), required=False, initial=self.plugin.config.get("categories", None), ) def <|fim_middle|>(self): """ A custom clean method to save category configuration information in a serializable form """ cleaned_data = super(CategoryLinksConfigForm, self).clean() categories = cleaned_data.get("categories", []) cleaned_data["categories"] = [category.pk for category in categories if hasattr(category, "pk")] return cleaned_data class CategoryLinksPlugin(TemplatedPlugin): """ A plugin for displaying links to visible categories on the shop front """ identifier = "category_links" name = _("Category Links") template_name = "shuup/xtheme/plugins/category_links.jinja" editor_form_class = CategoryLinksConfigForm fields = [ ("title", TranslatableField(label=_("Title"), required=False, initial="")), ("show_all_categories", forms.BooleanField( label=_("Show all categories"), required=False, initial=True, help_text=_("All categories are shown, even if not selected"), )), "categories", ] def get_context_data(self, context): """ A custom get_context_data method to return only visible categories for request customer. """ selected_categories = self.config.get("categories", []) show_all_categories = self.config.get("show_all_categories", True) request = context.get("request") categories = Category.objects.all_visible( customer=getattr(request, "customer"), shop=getattr(request, "shop") ) if not show_all_categories: categories = categories.filter(id__in=selected_categories) return { "title": self.get_translated_value("title"), "categories": categories, } <|fim▁end|>
clean
<|file_name|>category_links.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # This file is part of Shuup. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from django import forms from django.utils.translation import ugettext_lazy as _ from shuup.core.models import Category from shuup.xtheme import TemplatedPlugin from shuup.xtheme.plugins.forms import GenericPluginForm, TranslatableField class CategoryLinksConfigForm(GenericPluginForm): """ A configuration form for the CategoryLinksPlugin """ def populate(self): """ A custom populate method to display category choices """ for field in self.plugin.fields: if isinstance(field, tuple): name, value = field value.initial = self.plugin.config.get(name, value.initial) self.fields[name] = value self.fields["categories"] = forms.ModelMultipleChoiceField( queryset=Category.objects.all_visible(customer=None), required=False, initial=self.plugin.config.get("categories", None), ) def clean(self): """ A custom clean method to save category configuration information in a serializable form """ cleaned_data = super(CategoryLinksConfigForm, self).clean() categories = cleaned_data.get("categories", []) cleaned_data["categories"] = [category.pk for category in categories if hasattr(category, "pk")] return cleaned_data class CategoryLinksPlugin(TemplatedPlugin): """ A plugin for displaying links to visible categories on the shop front """ identifier = "category_links" name = _("Category Links") template_name = "shuup/xtheme/plugins/category_links.jinja" editor_form_class = CategoryLinksConfigForm fields = [ ("title", TranslatableField(label=_("Title"), required=False, initial="")), ("show_all_categories", forms.BooleanField( label=_("Show all categories"), required=False, initial=True, help_text=_("All categories are shown, even if not selected"), )), "categories", ] def <|fim_middle|>(self, context): """ A custom get_context_data method to return only visible categories for request customer. """ selected_categories = self.config.get("categories", []) show_all_categories = self.config.get("show_all_categories", True) request = context.get("request") categories = Category.objects.all_visible( customer=getattr(request, "customer"), shop=getattr(request, "shop") ) if not show_all_categories: categories = categories.filter(id__in=selected_categories) return { "title": self.get_translated_value("title"), "categories": categories, } <|fim▁end|>
get_context_data
<|file_name|>wsgi.py<|end_file_name|><|fim▁begin|>""" WSGI config for readbacks project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/<|fim▁hole|>""" import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "readbacks.settings") from django.core.wsgi import get_wsgi_application application = get_wsgi_application()<|fim▁end|>
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode)<|fim▁hole|> def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview<|fim▁end|>
mk_scrollable_area(listbox, listbox_frame, sbars) return listbox
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): <|fim_middle|> def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
__root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): <|fim_middle|> @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f)
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): <|fim_middle|> def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
return self.__root
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): <|fim_middle|> # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
self.__root.destroy() self.__root.quit()
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): <|fim_middle|> # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
pass
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): <|fim_middle|> def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): <|fim_middle|> def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1)
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): <|fim_middle|> def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): <|fim_middle|> <|fim▁end|>
BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone <|fim_middle|> else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] ))
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside <|fim_middle|> self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
self.__root = root
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone <|fim_middle|> else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True)
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside <|fim_middle|> self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
main_f = main_frame
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: <|fim_middle|> if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: <|fim_middle|> obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def <|fim_middle|>(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
__init__
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def <|fim_middle|>(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
root
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def <|fim_middle|>(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
close
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def <|fim_middle|>(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
make_widgets
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def <|fim_middle|>(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
params
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def <|fim_middle|>(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
mk_scrollable_area
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def <|fim_middle|>(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
mk_listbox
<|file_name|>common.py<|end_file_name|><|fim▁begin|>import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def <|fim_middle|>(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview <|fim▁end|>
mk_treeview
<|file_name|>apps.py<|end_file_name|><|fim▁begin|>""" Application file for the code snippets app. """ from django.apps import AppConfig from django.utils.translation import ugettext_lazy as _ class SnippetsConfig(AppConfig): """<|fim▁hole|> """ name = 'apps.snippets' verbose_name = _('Code snippets')<|fim▁end|>
Application configuration class for the code snippets app.
<|file_name|>apps.py<|end_file_name|><|fim▁begin|>""" Application file for the code snippets app. """ from django.apps import AppConfig from django.utils.translation import ugettext_lazy as _ class SnippetsConfig(AppConfig): <|fim_middle|> <|fim▁end|>
""" Application configuration class for the code snippets app. """ name = 'apps.snippets' verbose_name = _('Code snippets')
<|file_name|>rgb_led.py<|end_file_name|><|fim▁begin|>#! /usr/bin/env python """ This is an example that demonstrates how to use an RGB led with BreakfastSerial. It assumes you have an RGB led wired up with red on pin 10, green on pin 9, and blue on pin 8. """ from BreakfastSerial import RGBLed, Arduino from time import sleep board = Arduino() led = RGBLed(board, { "red": 10, "green": 9, "blue": 8 }) # Red (R: on, G: off, B: off) led.red() sleep(1) # Green (R: off, G: on, B: off) led.green() sleep(1)<|fim▁hole|>sleep(1) # Yellow (R: on, G: on, B: off) led.yellow() sleep(1) # Cyan (R: off, G: on, B: on) led.cyan() sleep(1) # Purple (R: on, G: off, B: on) led.purple() sleep(1) # White (R: on, G: on, B: on) led.white() sleep(1) # Off (R: off, G: off, B: off) led.off() # Run an interactive shell so you can play (not required) import code code.InteractiveConsole(locals=globals()).interact()<|fim▁end|>
# Blue (R: off, G: off, B: on) led.blue()
<|file_name|>tempdirtest.py<|end_file_name|><|fim▁begin|># -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- # # Copyright 2002 Ben Escoto <[email protected]> # Copyright 2007 Kenneth Loafman <[email protected]> # # This file is part of duplicity. # # Duplicity is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # Duplicity is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with duplicity; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import helper import sys, os, unittest from duplicity import tempdir helper.setup() class TempDirTest(unittest.TestCase): def test_all(self): td = tempdir.default() self.assert_(td.mktemp() != td.mktemp()) dir = td.mktemp() os.mkdir(dir) os.rmdir(dir) fd, fname = td.mkstemp() os.close(fd) os.unlink(fname) td.forget(fname) fo, fname = td.mkstemp_file() fo.close() # don't forget, leave to cleanup() <|fim▁hole|>if __name__ == "__main__": unittest.main()<|fim▁end|>
td.cleanup()
<|file_name|>tempdirtest.py<|end_file_name|><|fim▁begin|># -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- # # Copyright 2002 Ben Escoto <[email protected]> # Copyright 2007 Kenneth Loafman <[email protected]> # # This file is part of duplicity. # # Duplicity is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # Duplicity is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with duplicity; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import helper import sys, os, unittest from duplicity import tempdir helper.setup() class TempDirTest(unittest.TestCase): <|fim_middle|> if __name__ == "__main__": unittest.main() <|fim▁end|>
def test_all(self): td = tempdir.default() self.assert_(td.mktemp() != td.mktemp()) dir = td.mktemp() os.mkdir(dir) os.rmdir(dir) fd, fname = td.mkstemp() os.close(fd) os.unlink(fname) td.forget(fname) fo, fname = td.mkstemp_file() fo.close() # don't forget, leave to cleanup() td.cleanup()
<|file_name|>tempdirtest.py<|end_file_name|><|fim▁begin|># -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- # # Copyright 2002 Ben Escoto <[email protected]> # Copyright 2007 Kenneth Loafman <[email protected]> # # This file is part of duplicity. # # Duplicity is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # Duplicity is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with duplicity; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import helper import sys, os, unittest from duplicity import tempdir helper.setup() class TempDirTest(unittest.TestCase): def test_all(self): <|fim_middle|> if __name__ == "__main__": unittest.main() <|fim▁end|>
td = tempdir.default() self.assert_(td.mktemp() != td.mktemp()) dir = td.mktemp() os.mkdir(dir) os.rmdir(dir) fd, fname = td.mkstemp() os.close(fd) os.unlink(fname) td.forget(fname) fo, fname = td.mkstemp_file() fo.close() # don't forget, leave to cleanup() td.cleanup()
<|file_name|>tempdirtest.py<|end_file_name|><|fim▁begin|># -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- # # Copyright 2002 Ben Escoto <[email protected]> # Copyright 2007 Kenneth Loafman <[email protected]> # # This file is part of duplicity. # # Duplicity is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # Duplicity is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with duplicity; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import helper import sys, os, unittest from duplicity import tempdir helper.setup() class TempDirTest(unittest.TestCase): def test_all(self): td = tempdir.default() self.assert_(td.mktemp() != td.mktemp()) dir = td.mktemp() os.mkdir(dir) os.rmdir(dir) fd, fname = td.mkstemp() os.close(fd) os.unlink(fname) td.forget(fname) fo, fname = td.mkstemp_file() fo.close() # don't forget, leave to cleanup() td.cleanup() if __name__ == "__main__": <|fim_middle|> <|fim▁end|>
unittest.main()
<|file_name|>tempdirtest.py<|end_file_name|><|fim▁begin|># -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- # # Copyright 2002 Ben Escoto <[email protected]> # Copyright 2007 Kenneth Loafman <[email protected]> # # This file is part of duplicity. # # Duplicity is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # Duplicity is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with duplicity; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import helper import sys, os, unittest from duplicity import tempdir helper.setup() class TempDirTest(unittest.TestCase): def <|fim_middle|>(self): td = tempdir.default() self.assert_(td.mktemp() != td.mktemp()) dir = td.mktemp() os.mkdir(dir) os.rmdir(dir) fd, fname = td.mkstemp() os.close(fd) os.unlink(fname) td.forget(fname) fo, fname = td.mkstemp_file() fo.close() # don't forget, leave to cleanup() td.cleanup() if __name__ == "__main__": unittest.main() <|fim▁end|>
test_all
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book:<|fim▁hole|># # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: """A class that mimic's the built-in range class.""" def __init__(self, start, stop=None, step=1): """Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: raise ValueError('step cannot be 0') if stop is None: # special case of range(n) start, stop = 0, start # should be treated as if range(0,n) # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step def __len__(self): """Return number of entries in the range.""" return self._length def __getitem__(self, k): """Return entry at index k (using standard interpretation if negative).""" if k < 0: k += len(self) # attempt to convert negative index if not 0 <= k < self._length: raise IndexError('index out of range') return self._start + k * self._step<|fim▁end|>
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book: # # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: <|fim_middle|> <|fim▁end|>
"""A class that mimic's the built-in range class.""" def __init__(self, start, stop=None, step=1): """Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: raise ValueError('step cannot be 0') if stop is None: # special case of range(n) start, stop = 0, start # should be treated as if range(0,n) # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step def __len__(self): """Return number of entries in the range.""" return self._length def __getitem__(self, k): """Return entry at index k (using standard interpretation if negative).""" if k < 0: k += len(self) # attempt to convert negative index if not 0 <= k < self._length: raise IndexError('index out of range') return self._start + k * self._step
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book: # # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: """A class that mimic's the built-in range class.""" def __init__(self, start, stop=None, step=1): <|fim_middle|> def __len__(self): """Return number of entries in the range.""" return self._length def __getitem__(self, k): """Return entry at index k (using standard interpretation if negative).""" if k < 0: k += len(self) # attempt to convert negative index if not 0 <= k < self._length: raise IndexError('index out of range') return self._start + k * self._step <|fim▁end|>
"""Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: raise ValueError('step cannot be 0') if stop is None: # special case of range(n) start, stop = 0, start # should be treated as if range(0,n) # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book: # # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: """A class that mimic's the built-in range class.""" def __init__(self, start, stop=None, step=1): """Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: raise ValueError('step cannot be 0') if stop is None: # special case of range(n) start, stop = 0, start # should be treated as if range(0,n) # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step def __len__(self): <|fim_middle|> def __getitem__(self, k): """Return entry at index k (using standard interpretation if negative).""" if k < 0: k += len(self) # attempt to convert negative index if not 0 <= k < self._length: raise IndexError('index out of range') return self._start + k * self._step <|fim▁end|>
"""Return number of entries in the range.""" return self._length
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book: # # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: """A class that mimic's the built-in range class.""" def __init__(self, start, stop=None, step=1): """Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: raise ValueError('step cannot be 0') if stop is None: # special case of range(n) start, stop = 0, start # should be treated as if range(0,n) # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step def __len__(self): """Return number of entries in the range.""" return self._length def __getitem__(self, k): <|fim_middle|> <|fim▁end|>
"""Return entry at index k (using standard interpretation if negative).""" if k < 0: k += len(self) # attempt to convert negative index if not 0 <= k < self._length: raise IndexError('index out of range') return self._start + k * self._step
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book: # # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: """A class that mimic's the built-in range class.""" def __init__(self, start, stop=None, step=1): """Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: <|fim_middle|> if stop is None: # special case of range(n) start, stop = 0, start # should be treated as if range(0,n) # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step def __len__(self): """Return number of entries in the range.""" return self._length def __getitem__(self, k): """Return entry at index k (using standard interpretation if negative).""" if k < 0: k += len(self) # attempt to convert negative index if not 0 <= k < self._length: raise IndexError('index out of range') return self._start + k * self._step <|fim▁end|>
raise ValueError('step cannot be 0')
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book: # # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: """A class that mimic's the built-in range class.""" def __init__(self, start, stop=None, step=1): """Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: raise ValueError('step cannot be 0') if stop is None: # special case of range(n) <|fim_middle|> # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step def __len__(self): """Return number of entries in the range.""" return self._length def __getitem__(self, k): """Return entry at index k (using standard interpretation if negative).""" if k < 0: k += len(self) # attempt to convert negative index if not 0 <= k < self._length: raise IndexError('index out of range') return self._start + k * self._step <|fim▁end|>
start, stop = 0, start # should be treated as if range(0,n)
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book: # # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: """A class that mimic's the built-in range class.""" def __init__(self, start, stop=None, step=1): """Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: raise ValueError('step cannot be 0') if stop is None: # special case of range(n) start, stop = 0, start # should be treated as if range(0,n) # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step def __len__(self): """Return number of entries in the range.""" return self._length def __getitem__(self, k): """Return entry at index k (using standard interpretation if negative).""" if k < 0: <|fim_middle|> if not 0 <= k < self._length: raise IndexError('index out of range') return self._start + k * self._step <|fim▁end|>
k += len(self) # attempt to convert negative index
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book: # # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: """A class that mimic's the built-in range class.""" def __init__(self, start, stop=None, step=1): """Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: raise ValueError('step cannot be 0') if stop is None: # special case of range(n) start, stop = 0, start # should be treated as if range(0,n) # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step def __len__(self): """Return number of entries in the range.""" return self._length def __getitem__(self, k): """Return entry at index k (using standard interpretation if negative).""" if k < 0: k += len(self) # attempt to convert negative index if not 0 <= k < self._length: <|fim_middle|> return self._start + k * self._step <|fim▁end|>
raise IndexError('index out of range')
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book: # # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: """A class that mimic's the built-in range class.""" def <|fim_middle|>(self, start, stop=None, step=1): """Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: raise ValueError('step cannot be 0') if stop is None: # special case of range(n) start, stop = 0, start # should be treated as if range(0,n) # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step def __len__(self): """Return number of entries in the range.""" return self._length def __getitem__(self, k): """Return entry at index k (using standard interpretation if negative).""" if k < 0: k += len(self) # attempt to convert negative index if not 0 <= k < self._length: raise IndexError('index out of range') return self._start + k * self._step <|fim▁end|>
__init__
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book: # # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: """A class that mimic's the built-in range class.""" def __init__(self, start, stop=None, step=1): """Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: raise ValueError('step cannot be 0') if stop is None: # special case of range(n) start, stop = 0, start # should be treated as if range(0,n) # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step def <|fim_middle|>(self): """Return number of entries in the range.""" return self._length def __getitem__(self, k): """Return entry at index k (using standard interpretation if negative).""" if k < 0: k += len(self) # attempt to convert negative index if not 0 <= k < self._length: raise IndexError('index out of range') return self._start + k * self._step <|fim▁end|>
__len__
<|file_name|>range.py<|end_file_name|><|fim▁begin|># Copyright 2013, Michael H. Goldwasser # # Developed for use with the book: # # Data Structures and Algorithms in Python # Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser # John Wiley & Sons, 2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Range: """A class that mimic's the built-in range class.""" def __init__(self, start, stop=None, step=1): """Initialize a Range instance. Semantics is similar to built-in range class. """ if step == 0: raise ValueError('step cannot be 0') if stop is None: # special case of range(n) start, stop = 0, start # should be treated as if range(0,n) # calculate the effective length once self._length = max(0, (stop - start + step - 1) // step) # need knowledge of start and step (but not stop) to support __getitem__ self._start = start self._step = step def __len__(self): """Return number of entries in the range.""" return self._length def <|fim_middle|>(self, k): """Return entry at index k (using standard interpretation if negative).""" if k < 0: k += len(self) # attempt to convert negative index if not 0 <= k < self._length: raise IndexError('index out of range') return self._start + k * self._step <|fim▁end|>
__getitem__
<|file_name|>makevcf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys,os import textwrap def print_header(): print textwrap.dedent("""\ ##fileformat=VCFv4.1 ##phasing=none ##INDIVIDUAL=TRUTH ##SAMPLE=<ID=TRUTH,Individual="TRUTH",Description="bamsurgeon spike-in"> ##INFO=<ID=CIPOS,Number=2,Type=Integer,Description="Confidence interval around POS for imprecise variants"> ##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation"> ##INFO=<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant"> ##INFO=<ID=SVLEN,Number=.,Type=Integer,Description="Difference in length between REF and ALT alleles"> ##INFO=<ID=SOMATIC,Number=0,Type=Flag,Description="Somatic mutation in primary"> ##INFO=<ID=VAF,Number=1,Type=Float,Description="Variant Allele Frequency"> ##INFO=<ID=DPR,Number=1,Type=Float,Description="Avg Depth in Region (+/- 1bp)"> ##INFO=<ID=MATEID,Number=1,Type=String,Description="Breakend mate"> ##ALT=<ID=INV,Description="Inversion"> ##ALT=<ID=DUP,Description="Duplication"> ##ALT=<ID=DEL,Description="Deletion"> ##ALT=<ID=INS,Description="Insertion"> ##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype"> #CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tSPIKEIN""") if len(sys.argv) == 2: print_header() logdir_files = os.listdir(sys.argv[1]) for filename in logdir_files: if filename.endswith('.log'):<|fim▁hole|> #chrom, pos, mut = line.strip().split() c = line.strip().split() chrom = c[1].split(':')[0] pos = c[3] mut = c[4] dpr = c[6] vaf = c[7] ref,alt = mut.split('-->') print "\t".join((chrom,pos,'.',ref,alt,'100','PASS','SOMATIC;VAF=' + vaf + ';DPR=' + dpr,'GT','0/1')) else: print "usage:", sys.argv[0], "<log directory>"<|fim▁end|>
with open(sys.argv[1] + '/' + filename, 'r') as infile: for line in infile: if line.startswith('snv'):
<|file_name|>makevcf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys,os import textwrap def print_header(): <|fim_middle|> if len(sys.argv) == 2: print_header() logdir_files = os.listdir(sys.argv[1]) for filename in logdir_files: if filename.endswith('.log'): with open(sys.argv[1] + '/' + filename, 'r') as infile: for line in infile: if line.startswith('snv'): #chrom, pos, mut = line.strip().split() c = line.strip().split() chrom = c[1].split(':')[0] pos = c[3] mut = c[4] dpr = c[6] vaf = c[7] ref,alt = mut.split('-->') print "\t".join((chrom,pos,'.',ref,alt,'100','PASS','SOMATIC;VAF=' + vaf + ';DPR=' + dpr,'GT','0/1')) else: print "usage:", sys.argv[0], "<log directory>" <|fim▁end|>
print textwrap.dedent("""\ ##fileformat=VCFv4.1 ##phasing=none ##INDIVIDUAL=TRUTH ##SAMPLE=<ID=TRUTH,Individual="TRUTH",Description="bamsurgeon spike-in"> ##INFO=<ID=CIPOS,Number=2,Type=Integer,Description="Confidence interval around POS for imprecise variants"> ##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation"> ##INFO=<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant"> ##INFO=<ID=SVLEN,Number=.,Type=Integer,Description="Difference in length between REF and ALT alleles"> ##INFO=<ID=SOMATIC,Number=0,Type=Flag,Description="Somatic mutation in primary"> ##INFO=<ID=VAF,Number=1,Type=Float,Description="Variant Allele Frequency"> ##INFO=<ID=DPR,Number=1,Type=Float,Description="Avg Depth in Region (+/- 1bp)"> ##INFO=<ID=MATEID,Number=1,Type=String,Description="Breakend mate"> ##ALT=<ID=INV,Description="Inversion"> ##ALT=<ID=DUP,Description="Duplication"> ##ALT=<ID=DEL,Description="Deletion"> ##ALT=<ID=INS,Description="Insertion"> ##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype"> #CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tSPIKEIN""")
<|file_name|>makevcf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys,os import textwrap def print_header(): print textwrap.dedent("""\ ##fileformat=VCFv4.1 ##phasing=none ##INDIVIDUAL=TRUTH ##SAMPLE=<ID=TRUTH,Individual="TRUTH",Description="bamsurgeon spike-in"> ##INFO=<ID=CIPOS,Number=2,Type=Integer,Description="Confidence interval around POS for imprecise variants"> ##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation"> ##INFO=<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant"> ##INFO=<ID=SVLEN,Number=.,Type=Integer,Description="Difference in length between REF and ALT alleles"> ##INFO=<ID=SOMATIC,Number=0,Type=Flag,Description="Somatic mutation in primary"> ##INFO=<ID=VAF,Number=1,Type=Float,Description="Variant Allele Frequency"> ##INFO=<ID=DPR,Number=1,Type=Float,Description="Avg Depth in Region (+/- 1bp)"> ##INFO=<ID=MATEID,Number=1,Type=String,Description="Breakend mate"> ##ALT=<ID=INV,Description="Inversion"> ##ALT=<ID=DUP,Description="Duplication"> ##ALT=<ID=DEL,Description="Deletion"> ##ALT=<ID=INS,Description="Insertion"> ##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype"> #CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tSPIKEIN""") if len(sys.argv) == 2: <|fim_middle|> else: print "usage:", sys.argv[0], "<log directory>" <|fim▁end|>
print_header() logdir_files = os.listdir(sys.argv[1]) for filename in logdir_files: if filename.endswith('.log'): with open(sys.argv[1] + '/' + filename, 'r') as infile: for line in infile: if line.startswith('snv'): #chrom, pos, mut = line.strip().split() c = line.strip().split() chrom = c[1].split(':')[0] pos = c[3] mut = c[4] dpr = c[6] vaf = c[7] ref,alt = mut.split('-->') print "\t".join((chrom,pos,'.',ref,alt,'100','PASS','SOMATIC;VAF=' + vaf + ';DPR=' + dpr,'GT','0/1'))
<|file_name|>makevcf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys,os import textwrap def print_header(): print textwrap.dedent("""\ ##fileformat=VCFv4.1 ##phasing=none ##INDIVIDUAL=TRUTH ##SAMPLE=<ID=TRUTH,Individual="TRUTH",Description="bamsurgeon spike-in"> ##INFO=<ID=CIPOS,Number=2,Type=Integer,Description="Confidence interval around POS for imprecise variants"> ##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation"> ##INFO=<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant"> ##INFO=<ID=SVLEN,Number=.,Type=Integer,Description="Difference in length between REF and ALT alleles"> ##INFO=<ID=SOMATIC,Number=0,Type=Flag,Description="Somatic mutation in primary"> ##INFO=<ID=VAF,Number=1,Type=Float,Description="Variant Allele Frequency"> ##INFO=<ID=DPR,Number=1,Type=Float,Description="Avg Depth in Region (+/- 1bp)"> ##INFO=<ID=MATEID,Number=1,Type=String,Description="Breakend mate"> ##ALT=<ID=INV,Description="Inversion"> ##ALT=<ID=DUP,Description="Duplication"> ##ALT=<ID=DEL,Description="Deletion"> ##ALT=<ID=INS,Description="Insertion"> ##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype"> #CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tSPIKEIN""") if len(sys.argv) == 2: print_header() logdir_files = os.listdir(sys.argv[1]) for filename in logdir_files: if filename.endswith('.log'): <|fim_middle|> else: print "usage:", sys.argv[0], "<log directory>" <|fim▁end|>
with open(sys.argv[1] + '/' + filename, 'r') as infile: for line in infile: if line.startswith('snv'): #chrom, pos, mut = line.strip().split() c = line.strip().split() chrom = c[1].split(':')[0] pos = c[3] mut = c[4] dpr = c[6] vaf = c[7] ref,alt = mut.split('-->') print "\t".join((chrom,pos,'.',ref,alt,'100','PASS','SOMATIC;VAF=' + vaf + ';DPR=' + dpr,'GT','0/1'))
<|file_name|>makevcf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys,os import textwrap def print_header(): print textwrap.dedent("""\ ##fileformat=VCFv4.1 ##phasing=none ##INDIVIDUAL=TRUTH ##SAMPLE=<ID=TRUTH,Individual="TRUTH",Description="bamsurgeon spike-in"> ##INFO=<ID=CIPOS,Number=2,Type=Integer,Description="Confidence interval around POS for imprecise variants"> ##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation"> ##INFO=<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant"> ##INFO=<ID=SVLEN,Number=.,Type=Integer,Description="Difference in length between REF and ALT alleles"> ##INFO=<ID=SOMATIC,Number=0,Type=Flag,Description="Somatic mutation in primary"> ##INFO=<ID=VAF,Number=1,Type=Float,Description="Variant Allele Frequency"> ##INFO=<ID=DPR,Number=1,Type=Float,Description="Avg Depth in Region (+/- 1bp)"> ##INFO=<ID=MATEID,Number=1,Type=String,Description="Breakend mate"> ##ALT=<ID=INV,Description="Inversion"> ##ALT=<ID=DUP,Description="Duplication"> ##ALT=<ID=DEL,Description="Deletion"> ##ALT=<ID=INS,Description="Insertion"> ##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype"> #CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tSPIKEIN""") if len(sys.argv) == 2: print_header() logdir_files = os.listdir(sys.argv[1]) for filename in logdir_files: if filename.endswith('.log'): with open(sys.argv[1] + '/' + filename, 'r') as infile: for line in infile: if line.startswith('snv'): #chrom, pos, mut = line.strip().split() <|fim_middle|> else: print "usage:", sys.argv[0], "<log directory>" <|fim▁end|>
c = line.strip().split() chrom = c[1].split(':')[0] pos = c[3] mut = c[4] dpr = c[6] vaf = c[7] ref,alt = mut.split('-->') print "\t".join((chrom,pos,'.',ref,alt,'100','PASS','SOMATIC;VAF=' + vaf + ';DPR=' + dpr,'GT','0/1'))
<|file_name|>makevcf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys,os import textwrap def print_header(): print textwrap.dedent("""\ ##fileformat=VCFv4.1 ##phasing=none ##INDIVIDUAL=TRUTH ##SAMPLE=<ID=TRUTH,Individual="TRUTH",Description="bamsurgeon spike-in"> ##INFO=<ID=CIPOS,Number=2,Type=Integer,Description="Confidence interval around POS for imprecise variants"> ##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation"> ##INFO=<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant"> ##INFO=<ID=SVLEN,Number=.,Type=Integer,Description="Difference in length between REF and ALT alleles"> ##INFO=<ID=SOMATIC,Number=0,Type=Flag,Description="Somatic mutation in primary"> ##INFO=<ID=VAF,Number=1,Type=Float,Description="Variant Allele Frequency"> ##INFO=<ID=DPR,Number=1,Type=Float,Description="Avg Depth in Region (+/- 1bp)"> ##INFO=<ID=MATEID,Number=1,Type=String,Description="Breakend mate"> ##ALT=<ID=INV,Description="Inversion"> ##ALT=<ID=DUP,Description="Duplication"> ##ALT=<ID=DEL,Description="Deletion"> ##ALT=<ID=INS,Description="Insertion"> ##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype"> #CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tSPIKEIN""") if len(sys.argv) == 2: print_header() logdir_files = os.listdir(sys.argv[1]) for filename in logdir_files: if filename.endswith('.log'): with open(sys.argv[1] + '/' + filename, 'r') as infile: for line in infile: if line.startswith('snv'): #chrom, pos, mut = line.strip().split() c = line.strip().split() chrom = c[1].split(':')[0] pos = c[3] mut = c[4] dpr = c[6] vaf = c[7] ref,alt = mut.split('-->') print "\t".join((chrom,pos,'.',ref,alt,'100','PASS','SOMATIC;VAF=' + vaf + ';DPR=' + dpr,'GT','0/1')) else: <|fim_middle|> <|fim▁end|>
print "usage:", sys.argv[0], "<log directory>"
<|file_name|>makevcf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python import sys,os import textwrap def <|fim_middle|>(): print textwrap.dedent("""\ ##fileformat=VCFv4.1 ##phasing=none ##INDIVIDUAL=TRUTH ##SAMPLE=<ID=TRUTH,Individual="TRUTH",Description="bamsurgeon spike-in"> ##INFO=<ID=CIPOS,Number=2,Type=Integer,Description="Confidence interval around POS for imprecise variants"> ##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation"> ##INFO=<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant"> ##INFO=<ID=SVLEN,Number=.,Type=Integer,Description="Difference in length between REF and ALT alleles"> ##INFO=<ID=SOMATIC,Number=0,Type=Flag,Description="Somatic mutation in primary"> ##INFO=<ID=VAF,Number=1,Type=Float,Description="Variant Allele Frequency"> ##INFO=<ID=DPR,Number=1,Type=Float,Description="Avg Depth in Region (+/- 1bp)"> ##INFO=<ID=MATEID,Number=1,Type=String,Description="Breakend mate"> ##ALT=<ID=INV,Description="Inversion"> ##ALT=<ID=DUP,Description="Duplication"> ##ALT=<ID=DEL,Description="Deletion"> ##ALT=<ID=INS,Description="Insertion"> ##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype"> #CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tSPIKEIN""") if len(sys.argv) == 2: print_header() logdir_files = os.listdir(sys.argv[1]) for filename in logdir_files: if filename.endswith('.log'): with open(sys.argv[1] + '/' + filename, 'r') as infile: for line in infile: if line.startswith('snv'): #chrom, pos, mut = line.strip().split() c = line.strip().split() chrom = c[1].split(':')[0] pos = c[3] mut = c[4] dpr = c[6] vaf = c[7] ref,alt = mut.split('-->') print "\t".join((chrom,pos,'.',ref,alt,'100','PASS','SOMATIC;VAF=' + vaf + ';DPR=' + dpr,'GT','0/1')) else: print "usage:", sys.argv[0], "<log directory>" <|fim▁end|>
print_header
<|file_name|>urls.py<|end_file_name|><|fim▁begin|>"""schmankerl URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls import url, include from django.contrib import admin from schmankerlapp import views from django.contrib.auth import views as auth_views from django.conf.urls.static import static from django.conf import settings urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', views.home, name='home'), #restaurant url(r'^restaurant/sign-in/$', auth_views.login, {'template_name': 'restaurant/sign-in.html'}, name = 'restaurant-sign-in'), url(r'^restaurant/sign-out', auth_views.logout, {'next_page': '/'}, name='restaurant-sign-out'), url(r'^restaurant/sign-up', views.restaurant_sign_up, name='restaurant-sign-up'), url(r'^restaurant/$', views.restaurant_home, name='restaurant-home'), url(r'^restaurant/account/$', views.restaurant_account, name='restaurant-account'), url(r'^restaurant/meal/$', views.restaurant_meal, name='restaurant-meal'),<|fim▁hole|> url(r'^restaurant/report/$', views.restaurant_report, name='restaurant-report'), #sign-up, sign-in, sign-out url(r'^api/social/', include('rest_framework_social_oauth2.urls')), # /convert-token (sign-in, sign-out) # /revoke-token (sign-out) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)<|fim▁end|>
url(r'^restaurant/meal/add$', views.restaurant_add_meal, name='restaurant-add-meal'), url(r'^restaurant/order/$', views.restaurant_order, name='restaurant-order'),
<|file_name|>caching.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python ''' Import this module to have access to a global redis cache named GLOBAL_CACHE. <|fim▁hole|> GLOBAL_CACHE.store('foo', 'bar') GLOBAL_CACHE.get('foo') >> bar ''' from redis_cache import SimpleCache try: GLOBAL_CACHE except NameError: GLOBAL_CACHE = SimpleCache(limit=1000, expire=60*60*24, namespace="GLOBAL_CACHE") else: # Already defined... pass<|fim▁end|>
USAGE: from caching import GLOBAL_CACHE
<|file_name|>caching.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python ''' Import this module to have access to a global redis cache named GLOBAL_CACHE. USAGE: from caching import GLOBAL_CACHE GLOBAL_CACHE.store('foo', 'bar') GLOBAL_CACHE.get('foo') >> bar ''' from redis_cache import SimpleCache try: GLOBAL_CACHE except NameError: GLOBAL_CACHE = SimpleCache(limit=1000, expire=60*60*24, namespace="GLOBAL_CACHE") else: # Already defined... <|fim_middle|> <|fim▁end|>
pass
<|file_name|>_helpers.py<|end_file_name|><|fim▁begin|># Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.<|fim▁hole|> """Remove blank lines and region tags from sample text""" magic_lines = [ line for line in sample_text.split("\n") if len(line) > 0 and "# [" not in line ] return "\n".join(magic_lines)<|fim▁end|>
def strip_region_tags(sample_text):
<|file_name|>_helpers.py<|end_file_name|><|fim▁begin|># Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. def strip_region_tags(sample_text): <|fim_middle|> <|fim▁end|>
"""Remove blank lines and region tags from sample text""" magic_lines = [ line for line in sample_text.split("\n") if len(line) > 0 and "# [" not in line ] return "\n".join(magic_lines)
<|file_name|>_helpers.py<|end_file_name|><|fim▁begin|># Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. def <|fim_middle|>(sample_text): """Remove blank lines and region tags from sample text""" magic_lines = [ line for line in sample_text.split("\n") if len(line) > 0 and "# [" not in line ] return "\n".join(magic_lines) <|fim▁end|>
strip_region_tags
<|file_name|>wsgi.py<|end_file_name|><|fim▁begin|><|fim▁hole|> For more information on this file, see https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "asignacion_horario.settings") application = get_wsgi_application()<|fim▁end|>
""" WSGI config for horario project. It exposes the WSGI callable as a module-level variable named ``application``.
<|file_name|>check_key_import.py<|end_file_name|><|fim▁begin|>'''Manual check (not a discoverable unit test) for the key import, to identify problems with gnupg, gpg, gpg1, gpg2 and so on''' import os import shutil from gnupg import GPG def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]:<|fim▁hole|> print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg CRYPTO = setup_keyring("keyringtest") if CRYPTO: print("Ready", CRYPTO) KEY_LIST = CRYPTO.list_keys(False) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of public keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS) KEY_LIST = CRYPTO.list_keys(True) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of private keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS)<|fim▁end|>
with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result))
<|file_name|>check_key_import.py<|end_file_name|><|fim▁begin|>'''Manual check (not a discoverable unit test) for the key import, to identify problems with gnupg, gpg, gpg1, gpg2 and so on''' import os import shutil from gnupg import GPG def setup_keyring(keyring_name): <|fim_middle|> CRYPTO = setup_keyring("keyringtest") if CRYPTO: print("Ready", CRYPTO) KEY_LIST = CRYPTO.list_keys(False) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of public keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS) KEY_LIST = CRYPTO.list_keys(True) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of private keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS) <|fim▁end|>
'''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg
<|file_name|>check_key_import.py<|end_file_name|><|fim▁begin|>'''Manual check (not a discoverable unit test) for the key import, to identify problems with gnupg, gpg, gpg1, gpg2 and so on''' import os import shutil from gnupg import GPG def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: <|fim_middle|> return gpg CRYPTO = setup_keyring("keyringtest") if CRYPTO: print("Ready", CRYPTO) KEY_LIST = CRYPTO.list_keys(False) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of public keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS) KEY_LIST = CRYPTO.list_keys(True) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of private keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS) <|fim▁end|>
print("Got one import result")
<|file_name|>check_key_import.py<|end_file_name|><|fim▁begin|>'''Manual check (not a discoverable unit test) for the key import, to identify problems with gnupg, gpg, gpg1, gpg2 and so on''' import os import shutil from gnupg import GPG def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg CRYPTO = setup_keyring("keyringtest") if CRYPTO: <|fim_middle|> KEY_LIST = CRYPTO.list_keys(False) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of public keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS) KEY_LIST = CRYPTO.list_keys(True) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of private keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS) <|fim▁end|>
print("Ready", CRYPTO)
<|file_name|>check_key_import.py<|end_file_name|><|fim▁begin|>'''Manual check (not a discoverable unit test) for the key import, to identify problems with gnupg, gpg, gpg1, gpg2 and so on''' import os import shutil from gnupg import GPG def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg CRYPTO = setup_keyring("keyringtest") if CRYPTO: print("Ready", CRYPTO) KEY_LIST = CRYPTO.list_keys(False) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of public keys:", NUM_KEYS) if NUM_KEYS < 1: <|fim_middle|> KEY_LIST = CRYPTO.list_keys(True) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of private keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS) <|fim▁end|>
print("ERROR: Number of keys should be 1, not", NUM_KEYS)