# module pyparsing.py
#
# Copyright (c) 2003-2016 Paul T. McGuire
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__doc__ = \
"""
pyparsing module - Classes and methods to define and execute parsing grammars
The pyparsing module is an alternative approach to creating and executing simple grammars,
vs. the traditional lex/yacc approach, or the use of regular expressions. With pyparsing, you
don't need to learn a new syntax for defining grammars or matching expressions - the parsing module
provides a library of classes that you use to construct the grammar directly in Python.
Here is a program to parse "Hello, World!" (or any greeting of the form
C{"<salutation>, <addressee>!"}), built up using L{Word}, L{Literal}, and L{And} elements
(L{'+'<ParserElement.__add__>} operator gives L{And} expressions, strings are auto-converted to
L{Literal} expressions)::
from pip._vendor.pyparsing import Word, alphas
# define grammar of a greeting
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
print (hello, "->", greet.parseString(hello))
The program outputs the following::
Hello, World! -> ['Hello', ',', 'World', '!']
The Python representation of the grammar is quite readable, owing to the self-explanatory
class names, and the use of '+', '|' and '^' operators.
The L{ParseResults} object returned from L{ParserElement.parseString<ParserElement.parseString>} can be accessed as a nested list, a dictionary, or an
object with named attributes.
The pyparsing module handles some of the problems that are typically vexing when writing text parsers:
- extra or missing whitespace (the above program will also handle "Hello,World!", "Hello , World !", etc.)
- quoted strings
- embedded comments
"""
__version__ = "2.2.0"
__versionTime__ = "06 Mar 2017 02:06 UTC"
__author__ = "Paul McGuire <[email protected]>"
import string
from weakref import ref as wkref
import copy
import sys
import warnings
import re
import sre_constants
import collections
import pprint
import traceback
import types
from datetime import datetime
try:
from _thread import RLock
except ImportError:
from threading import RLock
try:
from collections import OrderedDict as _OrderedDict
except ImportError:
try:
from ordereddict import OrderedDict as _OrderedDict
except ImportError:
_OrderedDict = None
#~ sys.stderr.write( "testing pyparsing module, version %s, %s\n" % (__version__,__versionTime__ ) )
__all__ = [
'And', 'CaselessKeyword', 'CaselessLiteral', 'CharsNotIn', 'Combine', 'Dict', 'Each', 'Empty',
'FollowedBy', 'Forward', 'GoToColumn', 'Group', 'Keyword', 'LineEnd', 'LineStart', 'Literal',
'MatchFirst', 'NoMatch', 'NotAny', 'OneOrMore', 'OnlyOnce', 'Optional', 'Or',
'ParseBaseException', 'ParseElementEnhance', 'ParseException', 'ParseExpression', 'ParseFatalException',
'ParseResults', 'ParseSyntaxException', 'ParserElement', 'QuotedString', 'RecursiveGrammarException',
'Regex', 'SkipTo', 'StringEnd', 'StringStart', 'Suppress', 'Token', 'TokenConverter',
'White', 'Word', 'WordEnd', 'WordStart', 'ZeroOrMore',
'alphanums', 'alphas', 'alphas8bit', 'anyCloseTag', 'anyOpenTag', 'cStyleComment', 'col',
'commaSeparatedList', 'commonHTMLEntity', 'countedArray', 'cppStyleComment', 'dblQuotedString',
'dblSlashComment', 'delimitedList', 'dictOf', 'downcaseTokens', 'empty', 'hexnums',
'htmlComment', 'javaStyleComment', 'line', 'lineEnd', 'lineStart', 'lineno',
'makeHTMLTags', 'makeXMLTags', 'matchOnlyAtCol', 'matchPreviousExpr', 'matchPreviousLiteral',
'nestedExpr', 'nullDebugAction', 'nums', 'oneOf', 'opAssoc', 'operatorPrecedence', 'printables',
'punc8bit', 'pythonStyleComment', 'quotedString', 'removeQuotes', 'replaceHTMLEntity',
'replaceWith', 'restOfLine', 'sglQuotedString', 'srange', 'stringEnd',
'stringStart', 'traceParseAction', 'unicodeString', 'upcaseTokens', 'withAttribute',
'indentedBlock', 'originalTextFor', 'ungroup', 'infixNotation','locatedExpr', 'withClass',
'CloseMatch', 'tokenMap', 'pyparsing_common',
]
system_version = tuple(sys.version_info)[:3]
PY_3 = system_version[0] == 3
if PY_3:
_MAX_INT = sys.maxsize
basestring = str
unichr = chr
_ustr = str
# build list of single arg builtins, that can be used as parse actions
singleArgBuiltins = [sum, len, sorted, reversed, list, tuple, set, any, all, min, max]
else:
_MAX_INT = sys.maxint
range = xrange
def _ustr(obj):
"""Drop-in replacement for str(obj) that tries to be Unicode friendly. It first tries
str(obj). If that fails with a UnicodeEncodeError, then it tries unicode(obj). It
then < returns the unicode object | encodes it with the default encoding | ... >.
"""
if isinstance(obj,unicode):
return obj
try:
# If this works, then _ustr(obj) has the same behaviour as str(obj), so
# it won't break any existing code.
return str(obj)
except UnicodeEncodeError:
# Else encode it
ret = unicode(obj).encode(sys.getdefaultencoding(), 'xmlcharrefreplace')
xmlcharref = Regex(r'&#\d+;')
xmlcharref.setParseAction(lambda t: '\\u' + hex(int(t[0][2:-1]))[2:])
return xmlcharref.transformString(ret)
# build list of single arg builtins, tolerant of Python version, that can be used as parse actions
singleArgBuiltins = []
import __builtin__
for fname in "sum len sorted reversed list tuple set any all min max".split():
try:
singleArgBuiltins.append(getattr(__builtin__,fname))
except AttributeError:
continue
_generatorType = type((y for y in range(1)))
def _xml_escape(data):
"""Escape &, <, >, ", ', etc. in a string of data."""
# ampersand must be replaced first
from_symbols = '&><"\''
to_symbols = ('&'+s+';' for s in "amp gt lt quot apos".split())
for from_,to_ in zip(from_symbols, to_symbols):
data = data.replace(from_, to_)
return data
class _Constants(object):
pass
alphas = string.ascii_uppercase + string.ascii_lowercase
nums = "0123456789"
hexnums = nums + "ABCDEFabcdef"
alphanums = alphas + nums
_bslash = chr(92)
printables = "".join(c for c in string.printable if c not in string.whitespace)
class ParseBaseException(Exception):
"""base exception class for all parsing runtime exceptions"""
# Performance tuning: we construct a *lot* of these, so keep this
# constructor as small and fast as possible
def __init__( self, pstr, loc=0, msg=None, elem=None ):
self.loc = loc
if msg is None:
self.msg = pstr
self.pstr = ""
else:
self.msg = msg
self.pstr = pstr
没有合适的资源?快使用搜索试试~ 我知道了~
基于web的智能视频监控系统
共2000个文件
jpg:1814个
js:944个
svg:519个
需积分: 3 14 下载量 141 浏览量
2021-05-23
16:48:13
上传
评论 5
收藏 137.31MB RAR 举报
温馨提示
实现网页的实时人脸检测以及火焰检测,当检测到危险的时候进行系统的通知 相关部署实现请参照个人博客
资源推荐
资源详情
资源评论
收起资源包目录
基于web的智能视频监控系统 (2000个子文件)
activate 2KB
activate.bat 630B
deactivate.bat 368B
run.bat 57B
sysconfig.cfg 3KB
pyvenv.cfg 88B
adminlte.css 1.47MB
adminlte.min.css 1.32MB
adminlte.core.css 786KB
adminlte.core.min.css 691KB
adminlte.components.css 379KB
adminlte.components.min.css 345KB
adminlte.plugins.css 309KB
adminlte.plugins.min.css 283KB
bootstrap.css 191KB
bootstrap.rtl.css 190KB
bootstrap.rtl.min.css 151KB
bootstrap.min.css 151KB
all.css 72KB
fontawesome.css 70KB
bootstrap-grid.rtl.css 69KB
bootstrap-grid.css 69KB
bootstrap-utilities.css 67KB
bootstrap-utilities.rtl.css 67KB
all.min.css 58KB
fontawesome.min.css 57KB
bootstrap-grid.rtl.min.css 50KB
bootstrap-grid.min.css 50KB
bootstrap-utilities.min.css 50KB
bootstrap-utilities.rtl.min.css 50KB
bootstrap-4.css 43KB
v4-shims.css 40KB
adminlte.extra-components.css 40KB
main.css 39KB
flag-icon.css 37KB
jquery-ui.css 36KB
pace-theme-material.css 34KB
pace-theme-material.css 34KB
pace-theme-material.css 34KB
pace-theme-material.css 34KB
pace-theme-material.css 34KB
pace-theme-material.css 34KB
pace-theme-material.css 34KB
pace-theme-material.css 34KB
pace-theme-material.css 34KB
pace-theme-material.css 34KB
jsgrid-theme.css 34KB
adminlte.extra-components.min.css 34KB
bootstrap-4.min.css 34KB
flag-icon.min.css 33KB
jsgrid-theme.min.css 33KB
jquery-ui.min.css 31KB
summernote-lite.css 30KB
summernote-lite.min.css 30KB
sweetalert2.css 29KB
v4-shims.min.css 26KB
ambiance.css 26KB
main.min.css 24KB
sweetalert2.min.css 24KB
OverlayScrollbars.css 24KB
bootstrap-switch.css 23KB
adminlte.pages.css 20KB
OverlayScrollbars.min.css 20KB
bootstrap-switch.min.css 19KB
summernote-bs4.css 19KB
summernote.css 19KB
summernote-bs4.min.css 19KB
summernote.min.css 19KB
jquery-ui.structure.css 18KB
jquery-ui.theme.css 18KB
select2.css 17KB
adminlte.pages.min.css 16KB
jquery-ui.structure.min.css 15KB
icheck-bootstrap.css 15KB
select2.min.css 15KB
jquery-ui.theme.min.css 14KB
ion.rangeSlider.css 13KB
tempusdominus-bootstrap-4.css 13KB
icheck-bootstrap.min.css 12KB
bootstrap-slider.css 12KB
tempusdominus-bootstrap-4.min.css 12KB
dropzone.css 12KB
bootstrap-colorpicker.css 11KB
bootstrap-slider.min.css 11KB
ion.rangeSlider.min.css 11KB
searchPanes.bootstrap4.css 11KB
searchPanes.bootstrap4.min.css 10KB
dropzone.css 10KB
dropzone.min.css 10KB
searchBuilder.bootstrap4.css 10KB
bootstrap-colorpicker.min.css 9KB
pace-theme-loading-bar.css 9KB
pace-theme-loading-bar.css 9KB
pace-theme-loading-bar.css 9KB
pace-theme-loading-bar.css 9KB
pace-theme-loading-bar.css 9KB
pace-theme-loading-bar.css 9KB
pace-theme-loading-bar.css 9KB
pace-theme-loading-bar.css 9KB
pace-theme-loading-bar.css 9KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
天下一般
- 粉丝: 3244
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功