PATH: //opt/alt/python311/share/doc/alt-python311-pyparsing-doc/examples
FILE_BARU
CREATE
FOLDER_BARU
MKDIR
UPLOAD_FILE
GO
[ .. KEMBALI ]
📄 0README.html
↓
X
📄 AcManForm.dfm
↓
X
📄 LAparser.py
↓
X
📄 Setup.ini
↓
X
📄 SimpleCalc.py
↓
X
📄 SingleForm.dfm
↓
X
📄 TAP.py
↓
X
📄 __init__.py
↓
X
📁 __pycache__/
X
📄 adventureEngine.py
↓
X
📄 antlr_grammar.py
↓
X
📄 antlr_grammar_tests.py
↓
X
📄 apicheck.py
↓
X
📄 bigquery_view_parser.py
↓
X
📄 booleansearchparser.py
↓
X
📄 btpyparse.py
↓
X
📄 builtin_parse_action_demo.py
↓
X
📄 cLibHeader.py
↓
X
📄 chemicalFormulas.py
↓
X
📄 commasep.py
↓
X
📄 configParse.py
↓
X
📄 cpp_enum_parser.py
↓
X
📄 cuneiform_python.py
↓
X
📄 datetimeParseActions.py
↓
X
📄 decaf_parser.py
↓
X
📄 delta_time.py
↓
X
📄 dfmparse.py
↓
X
📄 dhcpd_leases_parser.py
↓
X
📄 dictExample.py
↓
X
📄 dictExample2.py
↓
X
📄 ebnf.py
↓
X
📄 ebnftest.py
↓
X
📄 eval_arith.py
↓
X
📄 excelExpr.py
↓
X
📄 fourFn.py
↓
X
📄 gen_ctypes.py
↓
X
📄 getNTPserversNew.py
↓
X
📄 greeting.py
↓
X
📄 greetingInGreek.py
↓
X
📄 greetingInKorean.py
↓
X
📄 groupUsingListAllMatches.py
↓
X
📄 holaMundo.py
↓
X
📄 htmlStripper.py
↓
X
📄 htmlTableParser.py
↓
X
📄 httpServerLogParser.py
↓
X
📄 idlParse.py
↓
X
📄 include_preprocessor.py
↓
X
📄 indentedGrammarExample.py
↓
X
📄 indented_block_example.py
↓
X
📄 invRegex.py
↓
X
📄 javascript_grammar.g
↓
X
📄 jsonParser.py
↓
X
📄 left_recursion.py
↓
X
📄 linenoExample.py
↓
X
📄 listAllMatches.py
↓
X
📄 lua_parser.py
↓
X
📄 lucene_grammar.py
↓
X
📄 macroExpander.py
↓
X
📄 make_diagram.py
↓
X
📄 matchPreviousDemo.py
↓
X
📄 mozilla.ics
↓
X
📄 mozillaCalendarParser.py
↓
X
📄 nested.py
↓
X
📄 nested_markup.py
↓
X
📄 number_words.py
↓
X
📄 numerics.py
↓
X
📄 oc.py
↓
X
📄 one_to_ninety_nine.py
↓
X
📄 parsePythonValue.py
↓
X
📄 parseResultsSumExample.py
↓
X
📄 parseTabularData.py
↓
X
📄 partial_gene_match.py
↓
X
📄 pgn.py
↓
X
📄 position.py
↓
X
📄 protobuf_parser.py
↓
X
📄 pymicko.py
↓
X
📄 pythonGrammarParser.py
↓
X
📄 railroad_diagram_demo.py
↓
X
📄 rangeCheck.py
↓
X
📄 readJson.py
↓
X
📄 removeLineBreaks.py
↓
X
📄 romanNumerals.py
↓
X
📄 rosettacode.py
↓
X
📄 scanExamples.py
↓
X
📄 searchParserAppDemo.py
↓
X
📄 searchparser.py
↓
X
📄 select_parser.py
↓
X
📄 sexpParser.py
↓
X
📄 shapes.py
↓
X
📄 simpleArith.py
↓
X
📄 simpleBool.py
↓
X
📄 simpleSQL.py
↓
X
📄 simpleWiki.py
↓
X
📄 snmp_api.h
↓
X
📄 sparser.py
↓
X
📄 sql2dot.py
↓
X
📄 stackish.py
↓
X
📁 statemachine/
X
📄 test_bibparse.py
↓
X
📄 unicode_denormalizer.py
↓
X
📄 urlExtractor.py
↓
X
📄 urlExtractorNew.py
↓
X
📁 verilog/
X
📄 verilogParse.py
↓
X
📄 withAttribute.py
↓
X
📄 wordsToNum.py
↓
X
SAVING...
BERHASIL DIUBAH!
EDITING: mozillaCalendarParser.py
from pyparsing import ( Optional, oneOf, Literal, Word, printables, Group, OneOrMore, ZeroOrMore, ) """ A simple parser for calendar (*.ics) files, as exported by the Mozilla calendar. Any suggestions and comments welcome. Version: 0.1 Copyright: Petri Savolainen <firstname.lastname@iki.fi> License: Free for any use """ # TERMINALS BEGIN = Literal("BEGIN:").suppress() END = Literal("END:").suppress() valstr = printables + "\xe4\xf6\xe5\xd6\xc4\xc5 " EQ = Literal("=").suppress() SEMI = Literal(";").suppress() COLON = Literal(":").suppress() EVENT = Literal("VEVENT").suppress() CALENDAR = Literal("VCALENDAR").suppress() ALARM = Literal("VALARM").suppress() # TOKENS CALPROP = oneOf("VERSION PRODID METHOD", asKeyword=True) ALMPROP = oneOf("TRIGGER", asKeyword=True) EVTPROP = oneOf( """X-MOZILLA-RECUR-DEFAULT-INTERVAL X-MOZILLA-RECUR-DEFAULT-UNITS UID DTSTAMP LAST-MODIFIED X RRULE EXDATE""", asKeyword=True ) valuestr = Word(valstr).setName("valuestr") propval = valuestr typeval = valuestr typename = oneOf("VALUE MEMBER FREQ UNTIL INTERVAL", asKeyword=True) proptype = Group(SEMI + typename + EQ + typeval).setName("proptype").suppress() calprop = Group(CALPROP + ZeroOrMore(proptype) + COLON + propval) almprop = Group(ALMPROP + ZeroOrMore(proptype) + COLON + propval) evtprop = ( Group(EVTPROP + ZeroOrMore(proptype) + COLON + propval).suppress() | "CATEGORIES" + COLON + propval.setResultsName("categories") | "CLASS" + COLON + propval.setResultsName("class") | "DESCRIPTION" + COLON + propval.setResultsName("description") | "DTSTART" + proptype + COLON + propval.setResultsName("begin") | "DTEND" + proptype + COLON + propval.setResultsName("end") | "LOCATION" + COLON + propval.setResultsName("location") | "PRIORITY" + COLON + propval.setResultsName("priority") | "STATUS" + COLON + propval.setResultsName("status") | "SUMMARY" + COLON + propval.setResultsName("summary") | "URL" + COLON + propval.setResultsName("url") ).setName("evtprop") calprops = Group(OneOrMore(calprop)).setName("calprops").suppress() evtprops = Group(OneOrMore(evtprop)) almprops = Group(OneOrMore(almprop)).setName("almprops").suppress() alarm = (BEGIN + ALARM + almprops + END + ALARM).setName("alarm") event = (BEGIN + EVENT + evtprops + Optional(alarm) + END + EVENT).setName("event") events = Group(OneOrMore(event)) calendar = (BEGIN + CALENDAR + calprops + ZeroOrMore(event) + END + CALENDAR).setName("calendar") calendars = OneOrMore(calendar) # PARSE ACTIONS def gotEvent(s, loc, toks): for event in toks: print(event.dump()) event.setParseAction(gotEvent) # MAIN PROGRAM if __name__ == "__main__": calendars.parseFile("mozilla.ics")
SIMPAN PERUBAHAN