本文整理汇总了Python中quanthistling.config.environment.load_environment函数的典型用法代码示例。如果您正苦于以下问题:Python load_environment函数的具体用法?Python load_environment怎么用?Python load_environment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_environment函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main(argv):
if len(argv) < 2:
print "call: updatecomponents.py ini_file"
exit(1)
ini_file = argv[1]
dictdata_path = 'quanthistling/dictdata'
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
# update languages
for c in quanthistling.dictdata.components.list:
db_lang = Session.query(model.Component).filter_by(name=c['name']).first()
if db_lang == None:
component = model.Component()
component.name = c['name']
component.description = c['description']
Session.add(component)
Session.commit()
print("Inserted component " + c['name'] + ".")
开发者ID:FrankNagel,项目名称:qlc,代码行数:26,代码来源:updatecomponents.py
示例2: main
def main(argv):
if len(argv) < 2:
print "call: updateversion.py ini_file"
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
new_version = False
corpusversion = Session.query(model.Corpusversion).filter_by(version=version,revision=revision).first()
if corpusversion == None:
corpusversion = model.Corpusversion()
new_version = True
corpusversion.version = version
corpusversion.revision = revision
corpusversion.updated = datetime.datetime.now()
if new_version:
Session.add(corpusversion)
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:25,代码来源:updateversion.py
示例3: main
def main(argv):
bibtex_key = u"jakway2008"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
#entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=109,pos_on_page=18).all()
#entries = []
startletters = set()
for e in entries:
if dictdata.startpage == 129:
heads = annotate_head_without_comma(e)
else:
heads = annotate_head(e)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
annotate_translations(e)
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()
for e in manual_entries:
dictdata = model.meta.Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).filter("startpage<=:pagenr and endpage>=:pagenr").params(pagenr=int(e["startpage"])).first()
entry_db = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id, startpage=e["startpage"], pos_on_page=e["pos_on_page"]).first()
if difflib.SequenceMatcher(None, e["fullentry"].decode('utf-8'), entry_db.fullentry).ratio() > 0.95:
entry_db.fullentry = e["fullentry"].decode('utf-8')
# delete all annotations in db
for a in entry_db.annotations:
Session.delete(a)
# insert new annotations
for a in e["annotations"]:
entry_db.append_annotation(a["start"], a["end"], a["value"].decode('utf-8'), a["type"].decode('utf-8'), a["string"].decode('utf-8'))
else:
print "We have a problem, manual entry on page %i pos %i seems not to be the same entry as in db, it was not inserted to db. Please correct the problem." % (e["startpage"], e["pos_on_page"])
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:60,代码来源:annotations_for_jakway2008.py
示例4: main
def main(argv):
if len(argv) < 2:
print "call: updatelanguages.py ini_file"
exit(1)
ini_file = argv[1]
dictdata_path = 'quanthistling/dictdata'
log = logging.getLogger()
logging.basicConfig(level=logging.INFO)
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
# update languages
for l in quanthistling.dictdata.languages.list:
db_lang = Session.query(model.LanguageIso).filter_by(name=l['name']).first()
if db_lang == None:
lname = l['name']
#lname = importfunctions.normalize_stroke(lname)
#lname = unicodedata.normalize("NFD", lname)
language = model.LanguageIso()
language.name = l['name']
language.langcode = l['langcode']
language.description = l['description']
language.url = l['url']
Session.add(language)
Session.commit()
log.info("Inserted language " + l['name'] + ".")
开发者ID:FrankNagel,项目名称:qlc,代码行数:34,代码来源:updatelanguages.py
示例5: main
def main(argv):
if len(argv) < 2:
print "call: exportheads.py ini_file"
exit(1)
ini_file = argv[1]
# load web application config
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create database session
metadata.create_all(bind=Session.bind)
# database queries for pos
annotations = model.meta.Session.query(model.Annotation).join(
(model.Entry, model.Annotation.entry_id==model.Entry.id),
(model.Dictdata, model.Entry.dictdata_id==model.Dictdata.id),
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Annotation.value==u"underline").all()
books = set()
for a in annotations:
books.add(a.entry.dictdata.book.bibtex_key)
print books
开发者ID:FrankNagel,项目名称:qlc,代码行数:28,代码来源:books_for_annotation_value.py
示例6: setup_app
def setup_app(command, conf, vars):
"""Place any commands to setup quanthistling here"""
thread.stack_size(512 * 1024)
# Don't reload the app if it was loaded under the testing environment
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
开发者ID:FrankNagel,项目名称:qlc,代码行数:10,代码来源:websetup.py
示例7: main
def main(argv):
bibtex_key = u"dooley2006"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
#entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=1,pos_on_page=4).all()
startletters = set()
for e in entries:
#split on newline, but ignore newline at pagebreak
pagebreaks = [b[0] for b in functions.get_list_ranges_for_annotation(e, 'pagebreak')]
newlines = [n[0] for n in functions.get_list_ranges_for_annotation(e, 'newline')
if not [ b for b in pagebreaks if abs(n[0] - b) < 3 ]]
lines = []
n = last = 0
for n in newlines:
lines.append((last, n))
last = n
lines.append((n, len(e.fullentry)))
heads = annotate_first_line(e, *lines.pop(0))
for l in lines:
heads.extend(annotate_secondary_line(e, *l))
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:48,代码来源:annotations_for_dooley2006.py
示例8: main
def main(argv):
bibtex_key = u"thiesen1998"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
# create orthography parser
base_qlc_path = "/media/Daten/Projects/git-github/qlc"
sys.path.append(os.path.join(base_qlc_path, "src"))
#import qlc.OrthographyProfile
#orthography_profile_location = os.path.join(base_qlc_path, "data", "orthography_profiles", "{0}.txt".format(bibtex_key))
#o_parser = qlc.OrthographyProfile.OrthographyProfile(orthography_profile_location)
# load dictionary data for this book
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
#entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=128,pos_on_page=18).all()
startletters = set()
for e in entries:
heads = annotate_head(e)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
annotate_pos(e)
annotate_translations(e)
annotate_examples(e)
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:47,代码来源:annotations_for_thiesen1998.py
示例9: main
def main(argv):
bibtex_key = u"morse1999"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
cmd = """\
delete from annotation
using book tb, entry te
where tb.bibtex_key = :bibtex_key and tb.id = te.book_id and te.id = entry_id
and annotationtype_id = (select id from annotationtype where type = 'dictinterpretation')"""
Session.execute(cmd, dict(bibtex_key=bibtex_key))
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
#entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=21,pos_on_page=12).all()
startletters = set()
for e in entries:
heads = annotate_everything(e)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
#annotate_dialect(e)
#annotate_pos(e)
#annotate_translations(e)
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:47,代码来源:annotations_for_morse1999.py
示例10: main
def main(argv):
bibtex_key = u"fastmowitz2008"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
#print "Processing %s - %s dictdata..." %(dictdata.src_language.langcode, dictdata.tgt_language.langcode)
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
#print len(entries)
#entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=343,pos_on_page=3).all()
#entries = []
startletters = set()
for e in entries:
heads = annotate_head(e)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
annotate_pos(e)
#Session.commit()
annotate_translations(e)
annotate_crossrefs(e)
annotate_dialect(e)
annotate_stratum(e)
#annotate_examples(e)
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:46,代码来源:annotations_for_fastmowitz2008.py
示例11: main
def main(argv):
bibtex_key = u"rolland1999"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
#entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=101,pos_on_page=23).all()
startletters = set()
for e in entries:
#skip subentries which start with '||'
if e.is_subentry and (e.fullentry.startswith('||') or e.fullentry.startswith(' ||')):
for a in e.annotations:
if a.annotationtype.type == 'dictinterpretation':
Session.delete(a)
continue
heads = annotate_head(e)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
annotate_pos(e)
annotate_translations(e)
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:46,代码来源:annotations_for_rolland1999.py
示例12: main
def main(argv):
bibtex_key = u"tuggy1966"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entry = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=345,pos_on_page=21).first()
if entry:
for a in entry.annotations:
Session.delete(a)
Session.delete(entry)
Session.commit()
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
# entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=1,pos_on_page=1).all()
startletters = set()
for e in entries:
heads = annotate_everything(e)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:45,代码来源:annotations_for_tuggy1966.py
示例13: main
def main(argv):
bibtex_key = u"gerdelslocum1983"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
# entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=21,pos_on_page=3).all()
# entries.extend(Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=2,pos_on_page=2).all())
# entries.extend(Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=2,pos_on_page=7).all())
startletters = set()
for e in entries:
try:
heads = annotate_head(e)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
annotate_pos(e)
annotate_translation(e)
except TypeError:
print " error on startpage: %i, pos_on_page: %i" % (e.startpage, e.pos_on_page)
raise
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:44,代码来源:annotations_for_gerdelslocum1983.py
示例14: main
def main(argv):
bibtex_key = u"parker2010a"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
#entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=15,pos_on_page=5).all()
startletters = set()
for e in entries:
#one time data conversion
if e.fullentry.find('[email protected]') != -1 or e.fullentry.find('[email protected]') != -1:
e.fullentry = e.fullentry.replace(u'[email protected]', u's\u0308').replace(u'[email protected]', u'c\u0308')
functions.print_error_in_entry(e, 'Replacing [email protected] and [email protected]')
heads = annotate_head(e)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
annotate_translations(e)
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:43,代码来源:annotations_for_parker2010a.py
示例15: make_app
def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
"""Create a Pylons WSGI application and return it
``global_conf``
The inherited configuration for this application. Normally from
the [DEFAULT] section of the Paste ini file.
``full_stack``
Whether this application provides a full WSGI stack (by default,
meaning it handles its own exceptions and errors). Disable
full_stack when this application is "managed" by another WSGI
middleware.
``static_files``
Whether this application serves its own static files; disable
when another web server is responsible for serving them.
``app_conf``
The application's local configuration. Normally specified in
the [app:<name>] section of the Paste ini file (where <name>
defaults to main).
"""
# Configure the Pylons environment
config = load_environment(global_conf, app_conf)
# The Pylons WSGI app
app = PylonsApp(config=config)
# Routing/Session/Cache Middleware
app = RoutesMiddleware(app, config['routes.map'])
app = SessionMiddleware(app, config)
# CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
if asbool(full_stack):
# Handle Python exceptions
app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
# Display error documents for 401, 403, 404 status codes (and
# 500 when debug is disabled)
if asbool(config['debug']):
app = StatusCodeRedirect(app)
else:
app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])
# Establish the Registry for this application
app = RegistryManager(app)
if asbool(static_files):
# Serve static files
static_app = StaticURLParser(config['pylons.paths']['static_files'])
app = Cascade([static_app, app])
app.config = config
return app
开发者ID:FrankNagel,项目名称:qlc,代码行数:55,代码来源:middleware.py
示例16: main
def main(argv):
bibtex_key = u'headland1997'
if len(argv) < 2:
print 'call: annotations_for%s.py ini_file' % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata)\
.join(model.Book, model.Dictdata.book_id == model.Book.id)\
.filter(model.Book.bibtex_key == bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
# entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=216,pos_on_page=16).all()
# entries.extend(Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=62,pos_on_page=7).all())
# entries.extend(Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=61,pos_on_page=1).all())
startletters = set()
for e in entries:
delete_dictinterpretation(e)
heads, start = annotate_head(e)
start = annotate_pos(e, start, len(e.fullentry))
annotate_translations(e, start, len(e.fullentry))
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
dictdata.startletters = unicode(repr(sorted(startletters)))
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:41,代码来源:annotations_for_headland1997.py
示例17: main
def main(argv):
bibtex_key = u'salzerchapman1998'
if len(argv) < 2:
print "call: annotations_for_%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id == model.Book.id)
).filter(model.Book.bibtex_key == bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
# entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=45,pos_on_page=2).all()
startletters = set()
for e in entries:
# print "current page: %i, pos_on_page: %i" % (e.startpage, e.pos_on_page)
heads, start = annotate_head_and_pos(e)
annotate_translation(e, start)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
dictdata.startletters = unicode(repr(sorted(startletters)))
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:39,代码来源:annotations_for_salzerchapman1998.py
示例18: main
def main(argv):
bibtex_key = u"loriot1993"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
#entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=92,pos_on_page=8).all()
#entries = []
startletters = set()
for e in entries:
heads = annotate_heads_and_crossrefs(e)
if not e.is_subentry:
for h in heads:
if len(h) > 0:
startletters.add(h[0].lower())
annotate_pos(e)
annotate_translations(e)
annotate_examples(e)
dictdata.startletters = unicode(repr(sorted(list(startletters))))
Session.commit()
开发者ID:FrankNagel,项目名称:qlc,代码行数:39,代码来源:annotations_for_loriot1993.py
示例19: main
def main(argv):
bibtex_key = u"burtch1983"
if len(argv) < 2:
print "call: annotations_for%s.py ini_file" % bibtex_key
exit(1)
ini_file = argv[1]
conf = appconfig('config:' + ini_file, relative_to='.')
if not pylons.test.pylonsapp:
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
metadata.create_all(bind=Session.bind)
dictdatas = Session.query(model.Dictdata).join(
(model.Book, model.Dictdata.book_id==model.Book.id)
).filter(model.Book.bibtex_key==bibtex_key).all()
for dictdata in dictdatas:
entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id).all()
#entries = Session.query(model.Entry).filter_by(dictdata_id=dictdata.id,startpage=19,pos_on_page=9).all()
for e in entries:
examples = []
for a in e.annotations:
if a.value == 'example-src' or a.value == 'example-tgt':
examples.append(a.string)
if len(examples) > 2:
if e.is_subentry:
url = url_for(controller='book', action='entryid', bibtexkey=bibtex_key, pagenr=e.mainentry().startpage, pos_on_page=e.mainentry().pos_on_page, format='html')
else:
url = url_for(controller='book', action='entryid', bibtexkey=bibtex_key, pagenr=e.startpage, pos_on_page=e.pos_on_page, format='html')
print e.fullentry.encode("utf-8") + '|' + url
开发者ID:FrankNagel,项目名称:qlc,代码行数:36,代码来源:get_burtch1983_entries_with_two_and_more_examples.py
示例20: main
def main(argv):
if len(argv) < 2:
print "call: exportbookdata.py ini_file"
exit(1)
ini_file = argv[1]
bibtex_key_param = None
if len(argv) >= 3:
bibtex_key_param = argv[2]
# load web application config
conf = appconfig('config:' + ini_file, relative_to='.')
config = None
if not pylons.test.pylonsapp:
config = load_environment(conf.global_conf, conf.local_conf)
# Create database session
metadata.create_all(bind=Session.bind)
for b in quanthistling.dictdata.wordlistbooks.list:
if bibtex_key_param != None and bibtex_key_param != b['bibtex_key']:
continue
book = model.meta.Session.query(model.Book).filter_by(bibtex_key=b['bibtex_key']).first()
if book:
print "Exporting data for %s..." % b['bibtex_key']
for wordlistdata in book.wordlistdata:
entries = model.meta.Session.query(model.WordlistEntry).join(
(model.Wordlistdata, model.WordlistEntry.wordlistdata_id==model.Wordlistdata.id)
).filter(model.Wordlistdata.id==wordlistdata.id).filter(model.WordlistEntry.has_manual_annotations==True).all()
# write heads to file
if len(entries) > 0:
for i in range(0,len(entries)):
fullentry = entries[i].fullentry
url = url_for(controller='book', action='entryid_wordlist', bibtexkey=b['bibtex_key'], concept=entries[i].concept.concept, language_bookname=wordlistdata.language_bookname, format='html')
print(fullentry.encode('utf-8') + "\thttp://www.cidles.eu/quanthistling" + url + "\n")
开发者ID:FrankNagel,项目名称:qlc,代码行数:40,代码来源:export_manual_entries_wordlists.py
注:本文中的quanthistling.config.environment.load_environment函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论