本文整理汇总了Python中mercurial.demandimport.enable函数的典型用法代码示例。如果您正苦于以下问题:Python enable函数的具体用法?Python enable怎么用?Python enable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enable函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: critique
def critique(ui, repo, entire=False, node=None, **kwargs):
"""Perform a critique of a changeset."""
demandimport.disable()
from flake8.engine import get_style_guide
from pep8 import DiffReport, parse_udiff
style = get_style_guide(parse_argv=False, ignore='E128')
ctx = repo[node]
if not entire:
diff = ''.join(ctx.diff())
style.options.selected_lines = {}
for k, v in parse_udiff(diff).items():
if k.startswith('./'):
k = k[2:]
style.options.selected_lines[k] = v
style.options.report = DiffReport(style.options)
deleted = repo.status(ctx.p1().node(), ctx.node())[2]
files = [f for f in ctx.files() if f.endswith('.py') and f not in deleted]
style.check_files(files)
demandimport.enable()
示例2: launch_browser
def launch_browser(ui, request_url):
# not all python installations have the webbrowser module
from mercurial import demandimport
demandimport.disable()
try:
import webbrowser
webbrowser.open(request_url)
except:
ui.status('unable to launch browser - webbrowser module not available.')
demandimport.enable()
示例3: hgweb_handler
def hgweb_handler(environ, start_response):
from mercurial import demandimport; demandimport.enable()
#from mercurial.hgweb.hgwebdir_mod import hgwebdir
#from mercurial.hgweb.request import wsgiapplication
from mercurial.hgweb import hgweb
hgweb_conf = '/etc/mercurial/hgweb.conf'
#make_web_app = hgwebdir(hgweb_conf)
hg_webapp = hgweb(hgweb_conf)
#hg_webapp = wsgiapplication(make_web_app)
return hg_webapp(environ, start_response)
示例4: addcommand
import sys, os.path, re
from datetime import datetime
import time
from math import ceil
sys.path.append(os.path.dirname(__file__))
demandimport.disable()
from parsedatetime import parsedatetime as pdt
try:
import sqlite3 as sqlite
except ImportError:
from pysqlite2 import dbapi2 as sqlite
demandimport.enable()
testedwith = '3.6'
cal = pdt.Calendar()
PUSHES_PER_PAGE = 10
def addcommand(f, name):
setattr(hgwebprotocol, name, f)
hgwebprotocol.__all__.append(name)
def addwebcommand(f, name):
setattr(hgwebcommands, name, f)
hgwebcommands.__all__.append(name)
ATOM_MIMETYPE = 'application/atom+xml'
示例5: getattr
import sys
# Adjust python path if this is not a system-wide install
#sys.path.insert(0, r'c:\path\to\python\lib')
# Enable tracing. Run 'python -m win32traceutil' to debug
if getattr(sys, 'isapidllhandle', None) is not None:
import win32traceutil
# To serve pages in local charset instead of UTF-8, remove the two lines below
import os
os.environ['HGENCODING'] = 'UTF-8'
import isapi_wsgi
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir
# Example tweak: Replace isapi_wsgi's handler to provide better error message
# Other stuff could also be done here, like logging errors etc.
class WsgiHandler(isapi_wsgi.IsapiWsgiHandler):
error_status = '500 Internal Server Error' # less silly error message
isapi_wsgi.IsapiWsgiHandler = WsgiHandler
# Only create the hgwebdir instance once
application = hgwebdir(hgweb_config)
def handler(environ, start_response):
# Translate IIS's weird URLs
示例6: add_domain
def add_domain(a,b):
pass
hg_import_error = []
try:
# The new `demandimport` mechanism doesn't play well with code relying
# on the `ImportError` exception being caught.
# OTOH, we can't disable `demandimport` because mercurial relies on it
# (circular reference issue). So for now, we activate `demandimport`
# before loading mercurial modules, and desactivate it afterwards.
#
# See http://www.selenic.com/mercurial/bts/issue605
try:
from mercurial import demandimport
demandimport.enable();
except ImportError, hg_import_error:
demandimport = None
from mercurial import hg
from mercurial.context import filectx
from mercurial.ui import ui
from mercurial.node import hex, short, nullid
from mercurial.util import pathto, cachefunc
from mercurial import cmdutil
from mercurial import extensions
from mercurial.extensions import loadall
# Note: due to the nature of demandimport, there will be no actual
# import error until those symbols get accessed, so here we go:
for sym in ("filectx ui hex short nullid pathto "