#-*- coding: utf-8 -*-
# module pyparsing.py
#
# Copyright (c) 2003-2019 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
``"<salutation>, <addressee>!"``), built up using :class:`Word`,
:class:`Literal`, and :class:`And` elements
(the :class:`'+'<ParserElement.__add__>` operators create :class:`And` expressions,
and the strings are auto-converted to :class:`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 :class:`ParseResults` object returned from
:class:`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
Getting Started -
-----------------
Visit the classes :class:`ParserElement` and :class:`ParseResults` to
see the base classes that most other pyparsing
classes inherit from. Use the docstrings for examples of how to:
- construct literal match expressions from :class:`Literal` and
:class:`CaselessLiteral` classes
- construct character word-group expressions using the :class:`Word`
class
- see how to create repetitive expressions using :class:`ZeroOrMore`
and :class:`OneOrMore` classes
- use :class:`'+'<And>`, :class:`'|'<MatchFirst>`, :class:`'^'<Or>`,
and :class:`'&'<Each>` operators to combine simple expressions into
more complex ones
- associate names with your parsed results using
:class:`ParserElement.setResultsName`
- find some helpful expression short-cuts like :class:`delimitedList`
and :class:`oneOf`
- find more useful common expressions in the :class:`pyparsing_common`
namespace class
"""
__version__ = "2.3.1"
__versionTime__ = "09 Jan 2019 23:26 UTC"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
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:
# Python 3
from itertools import filterfalse
except ImportError:
from itertools import ifilterfalse as filterfalse
try:
from _thread import RLock
except ImportError:
from threading import RLock
try:
# Python 3
from collections.abc import Iterable
from collections.abc import MutableMapping
except ImportError:
# Python 2.7
from collections import Iterable
from collections import MutableMapping
try:
from collections import OrderedDict as _OrderedDict
except ImportError:
try:
from ordereddict import OrderedDict as _OrderedDict
except ImportError:
_OrderedDict = None
try:
from types import SimpleNamespace
except ImportError:
class SimpleNamespace: pass
#~ 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',
'PrecededBy', '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', 'Char',
'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', 'pyparsing_unicode', 'unicode_set',
]
system_version = tuple(sys.version_info)[:3]
PY_3 = system_version[0] == 3
if PY_3:
_MAX_INT = sys.maxsize
basestring = str
unichr = chr
unicode = str
_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 ver
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
毕业设计基于pythonWeb开发Django框架的图书商城管理系统源码。 软件架构:python的web开发Django框架 安装教程 在命令行中输入python manage.py runserver 运行商城。 注意:要在web里的目录下才能运行manage.py 文件哦! 使用说明 图书商城管理系统 1,图书商城前台首页,有图书分类,精品图书,和注册、登陆页面,还可以通过点图书列表页的快速预览进去图书详情页,图书加入购物车页。 针对一些图书商城管理工作效率较低,图书管理的体系不健全、不完善,图书管理缺乏科学规划作出的项目。
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计基于pythonWeb开发Django框架的图书商城管理系统源码+数据库文件.zip (2000个子文件)
bootstrap.min.css 118KB
bootstrap-theme.css 116KB
style.css 96KB
bootstrap.min.css 95KB
font-awesome.css 37KB
jquery-ui-1.10.1.custom.css 31KB
style.css 31KB
font-awesome.min.css 30KB
font-awesome.min.css 30KB
editor_ie7.css 29KB
editor_iequirks.css 28KB
editor_ie8.css 27KB
editor_ie.css 27KB
jquery-ui-1.10.4.min.css 27KB
jquery-ui-1.10.1.custom.min.css 26KB
editor_gecko.css 26KB
editor.css 26KB
elegant-icons-style.css 25KB
theme.css 20KB
base.css 19KB
responsive.css 18KB
select2.css 17KB
bootstrap-datepicker.css 17KB
dialog_ie7.css 16KB
dialog_ie8.css 16KB
dialog_iequirks.css 16KB
dialog_ie.css 16KB
dialog_opera.css 15KB
dialog.css 15KB
select2.min.css 15KB
bootstrap-colorpicker.css 14KB
bootstrap-fullcalendar.css 12KB
widgets.css 11KB
fullcalendar.css 10KB
fullcalendar.css 10KB
autocomplete.css 9KB
forms.css 9KB
daterangepicker.css 8KB
style-responsive.css 7KB
changelists.css 7KB
widgets.css 7KB
style.css 5KB
sample.css 5KB
xcharts.min.css 4KB
styles.css 4KB
style.css 4KB
styles.css 4KB
nouislider.min.css 3KB
rtl.css 3KB
slick-theme.css 3KB
mocha-1.6.0.css 3KB
line-icons.css 2KB
nav_sidebar.css 2KB
outputxhtml.css 2KB
slick.css 2KB
responsive_rtl.css 2KB
prettify.css 2KB
contents.css 1KB
owl.carousel.css 1KB
fullcalendar.print.css 1KB
toolbar.css 1KB
wsc.css 1KB
login.css 939B
jquery-jvectormap-1.2.2.css 744B
prettify.css 675B
ol3.css 657B
morris.css 605B
fonts.css 423B
dashboard.css 380B
example.css 158B
jquery.easy-pie-chart.css 141B
sample.css 50B
index.html 27KB
technical_500.html 17KB
base.html 17KB
detail.html 14KB
index.html 13KB
base.html 12KB
list.html 12KB
index.html 12KB
default_urlconf.html 11KB
index.html 11KB
blank.html 11KB
inlineall.html 9KB
outputforflash.html 9KB
index.html 8KB
index.html 8KB
toolbar.html 8KB
magicline.html 8KB
fullpage.html 7KB
outputhtml.html 7KB
dialog.html 7KB
replacebyclass.html 7KB
api.html 7KB
replacebycode.html 7KB
xhtmlstyle.html 6KB
inlinebycode.html 6KB
add.html 6KB
register.html 5KB
index.html 5KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
程序员张小妍
- 粉丝: 1w+
- 资源: 2777
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页