offlineimap rev 492
"Automatic Subversion Change Mailer" <[email protected]> Wed, 16 Jul 2003 11:03:30 -0500 (CDT)
| Newsgroups | gmane.mail.imap.offlineimap.subversion |
|---|---|
| Message-ID | <[email protected]> |
You are receiving this message because
all commits get sent to this address.
Author: jgoerzen
Date: 2003-07-16 11:02:46 -0500 (Wed, 16 Jul 2003)
New Revision: 492
Modified:
imaplib/head/Makefile
imaplib/head/imap2/parser/imap.g
imaplib/head/runtests.py
imaplib/head/runtestsgui.py
Log:
Added some new rules from the beginning
Diff:
Modified: imaplib/head/Makefile
==============================================================================
--- imaplib/head/Makefile 2003-07-16 14:29:59 UTC (rev 491)
+++ imaplib/head/Makefile 2003-07-16 16:02:46 UTC (rev 492)
@@ -15,9 +15,19 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
SHELL=/bin/bash
+PYTHON=python2.2
+all: parser
+
+parser: imap2/parser/imap.py
+
+imap2/parser/imap.py: imap2/parser/imap.g
+ -rm imap2/parser/imap.py
+ $(PYTHON) contrib/yapps2/yapps2.py imap2/parser/imap.g
+ test -f imap2/parser/imap.py
+
clean:
- -python2.2 setup.py clean --all
+ -$(PYTHON) setup.py clean --all
-rm -f `find . -name "*~"`
-rm -f `find . -name "*.tmp"`
-rm -f bin/offlineimapc
Modified: imaplib/head/imap2/parser/imap.g
==============================================================================
--- imaplib/head/imap2/parser/imap.g 2003-07-16 14:29:59 UTC (rev 491)
+++ imaplib/head/imap2/parser/imap.g 2003-07-16 16:02:46 UTC (rev 492)
@@ -1,12 +1,209 @@
+# Implementation of grammar from RFC3501
+
+
parser IMAP:
token END: "$"
+
+
+ # custom tokens
- token alpha: r'[a-zA-Z]'
+ token LPAREN: r'\('
+ token RPAREN: r'\)'
+ token PLUS: r'\+'
+ token DASH: r'-'
+
+ # Tokens in RFC2060, missing from RFC3501, but used there.
+ token ALPHA: r'[a-zA-Z]'
+ token DQUOTE: r'"'
+
+
+ # Rules
+
+ rule address: LPAREN addr-name SP addr-adl SP addr-mailbox SP
+ addr-host RPAREN
+ {{ return {'name': addr-name, 'adl': addr-adl,
+ 'mailbox': addr-mailbox, 'host': addr-host} }}
+
+ rule addr-adl: nstring {{ return nstring }}
+ rule addr-host: nstring {{ return nstring }}
+ rule addr-mailbox: nstring {{ return nstring }}
+ rule addr-name: nstring {{ return nstring }}
+ # append
+ rule astring: string {{ return string }} |
+ {{ v = '' }}
+ ( ASTRING_CHAR {{ v += ASTRING_CHAR }} ) +
+ {{ return v }}
+ rule atom: {{ v = '' }} ( ATOM_CHAR {{ v += ATOM_CHAR }} ) + {{ return v }}
+ rule ASTRING_CHAR: ATOM_CHAR {{ return ATOM_CHAR}}
+ | resp_specials {{ return resp_specials }}
+ token ATOM_CHAR: r'(?![(){ \x00-\x1f\x7f%*"\\\]])[\x01-\x7f]'
+ token atom_specials_tok: r'[()}'
+ rule atom_specials: atom_specials_tok {{ return atom_specials_tok }}
+ | SP {{ return SP }}
+ | CTL {{ return CTL }}
+ | list_wildcards {{ return list_wildcards }}
+ | quoted_specials {{ return quoted_specials }}
+ | resp_specials {{ return resp_specials}}
+ rule authenticate: "(?i)AUTHENTICATE" SP
+ auth_type {{ v = {'auth_type': auth_type} }}
+ [ CRLF base64 {{ v['base64'] = base64 }} ]
+ {{ return v }}
+ rule auth_type: atom {{ return atom }}
+
+ ##############################
+ # B
+ ##############################
+
+ rule base64: {{ v = '' }}
+ (base64_char_x4 {{ v += base64_char_x4}} ) *
+ [ base64_terminal {{ v += base64_terminal }} ]
+ {{ return v }}
+ token base64_char: r'[a-zA-Z0-9+/]'
+ token base64_char_x2: r'[a-zA-Z0-9+/]{2}'
+ token base64_char_x3: r'[a-zA-Z0-9+/]{3}'
+ token base64_char_x4: r'[a-zA-Z0-9+/]{4}'
+ rule base64_terminal: (base64_char_x2 "==" {{ return base64_char_x2 + "==" }}
+ | base64_char_x3 "=" {{ return base64_char_x3 + "=" }}
+ )
+
+ rule body: LPAREN (body_type_1part {{ return body_type_1part }}
+ | body_type_mpart {{ return body_type_mpart }} ) RPAREN
+ rule body_extension: (nstring {{ v = nstring }}
+ | number {{ v = number }}
+ | (LPAREN body_extension {{ v = [body_extension] }}
+ (SP body_extension {{ v.append(body_extension)}} ) * )
+ )
+ {{ return v }}
+ rule body_ext_1part: body_fld_md5 {{ v = {'md5': body_fld_md5, 'extension': []} }}
+ [SP body_fld_dsp {{ v['dsp']: body_fld_dsp}}
+ [SP body_fld_lang {{ v['lang']: body_fld_lang}}
+ [SP body_fld_loc {{ v['loc']: body_fld_loc }}
+ (SP body_extension {{ v['extension'].append(body_extension)}}) *
+ ]
+ ]
+ ]
+ {{ return v }}
+ rule body_ext_mpart: body_fld_param {{ v = {'param': body_fld_param, 'extension': []} }}
+ [SP body_fld_dsp {{ v['dsp']: body_fld_dsp }}
+ [SP body_fld_lang {{ v['lang']: body_fld_lang}}
+ [SP body_fld_loc {{ v['loc']: body_fld_loc}}
+ (SP body_extension {{ v['extension'].append(body_extension)}} )*
+ ]
+ ]
+ ]
+ {{ return v }}
+ rule body_fields: body_fld_param SP body_fld_id SP body_fld_desc SP
+ body_fld_enc SP body_fld_octets
+ {{ return {'param': body_fld_param, 'id': body_fld_id,
+ 'desc': body_fld_desc, 'enc': body_fld_enc,
+ 'octets': body_fld_octets} }}
+ rule body_fld_desc: nstring {{ return nstring }}
+ rule body_fld_dsp: (nil {{ v = nil }}
+ | LPAREN string SP body_fld_param RPAREN {{ v = [string, body_fld_param] }}
+ )
+ {{ return v }}
+ rule body_fld_enc: string {{return string}}
+ rule body_fld_id: nstring {{ return nstring }}
+ rule body_fld_lang: ( nstring {{ v = [nstring] }}
+ | LPAREN string {{ v = [string] }}
+ (SP string {{ v.append(string) }} ) *
+ ) {{ return v }}
+ rule body_fld_loc: nstring {{ return nstring }}
+ rule body_fld_lines: number {{ return number }}
+ rule body_fld_md5: nstring {{ return nstring }}
+ rule body_fld_octets: number {{ return number }}
+ rule body_fld_param: (nil {{ v = nil }}
+ |
+ LPAREN {{ v = [] }}
+ string {{ x = string }}
+ SP string {{ v.append([x, string]) }}
+ (SP string {{ x = string }}
+ SP string {{ v.append([x, string]) }})*
+ RPAREN ) {{ return v }}
+
+ rule body_type_1part: (body_type_basic {{ v = [body_type_basic] }}
+ | body_type_msg {{ v = [body_type_msg] }}
+ | body_type_text {{ v = [body_type_text] }}
+ )
+ [SP body_ext_1part {{v.append(body_ext_1part) }} ]
+ {{ return v}}
+ rule body_type_basic: media_basic {{ v = {'media_basic': media_basic} }}
+ SP body_fields {{ v['body_fields']: body_fields }}
+ {{ return v }}
+ rule body_type_mpart: {{ v_body = []}} (body {{v_body.append(body)}} )+
+ {{ v = {'body': v_body} }}
+ SP media_subtype {{v['media_subtype']: media_subtype}}
+ [SP body_ext_mpart {{v['body_ext_mpart']: body_ext_mpart}} ]
+ {{ return v }}
+ rule body_type_msg: media_message SP body_fields SP envelope SP
+ body SP body_fld_lines
+ {{ return {'media_message': media_message,
+ 'body_fields': body_fields,
+ 'envelope': envelope, 'body': body,
+ 'bofy_fld_lines': body_fld_lines} }}
+ rule body_type_text: media_text SP body_fields SP body_fld_lines
+ {{ return {'media_text': media_text, 'body_fields': body_fields,
+ 'body_fld_lines': body_fld_lines} }}
+
+ ##############################
+ # C
+ ##############################
+
+ rule capability: ("(?i)AUTH=" auth_type {{ v = "AUTH=" + auth_type }}
+ | atom {{ v = atom }} ) {{ return v }}
+ rule capability_data: "(?i)CAPABILITY" {{ v = [] }}
+ (SP capability {{ v.append(capability) }})*
+ "(?i)IMAP4rev1" {{ v.append("IMAP4rev1") }}
+ (SP capability {{ v.append(capability) }})*
+ {{ return v }}
+ token CHAR8: r'[\x01-\xff]'
+
+ #rule command:
+ #rule command_any:
+ #rule command_auth:
+ #rule command_nonauth:
+ #rule command_select:
+
+ rule continue_req: PLUS SP (resp_text {{ v = resp_text}}
+ | base64 {{ v = base64}} )
+ CRLF {{ return v }}
+ # rule copy:
+ # rule create:
+ rule date: (date_text | DQUOTE date_text DQUOTE) {{ return date_text }}
+ token date_day: r'[0-9]{1,2}'
+ token date_day_fixed: r'[ 0-9][0-9]'
+ token date_month: r'(?i)(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'
+ rule date_text: date_day DASH date_month DASH date_year
+ {{ return {'day': int(date_day),
+ 'month': date_month,
+ 'year': int(date_year)} }}
+ token date_year: r'[0-9]{4}'
+ rule date_time: DQUOTE date_day_fixed DASH date_month DASH date_year
+ SP time SP zone DQUOTE {{ return {'day': int(date_day_fixed.strip()),
+ 'month': date_month,
+ 'year': int(date_year),
+ 'time': time, 'zone': zone} }}
+ # rule delete:
+ token digit_nz: r'[1-9]'
+
+ ##############################
+ # E
+ ##############################
+
+
+
+
+
+
+
+
+ rule address:
+
token ATOM_CHAR: r'(?![(){ %("\\\x00-\x1f\x7f])[\x01-\x7f]'
token CHAR: r'[\x01-\x7f]'
token CHAR8: r'[\x01-\xff]'
+ token CRLF: r'\x0d\x0a'
token CTL: r'[\x00-\x1f\x7f]'
- token CRLF: r'\x0d\x0a'
token digit: r'[0-9]'
token digit_nz: r'[1-9]'
token list_wildcards: r'[%*]'
@@ -36,10 +233,10 @@
"/" {{ return '/' }}
rule base64_char_x4: {{ v = '' }}
- baes64_char {{ v += base64_char }}
- baes64_char {{ v += base64_char }}
- baes64_char {{ v += base64_char }}
- baes64_char {{ v += base64_char }}
+ base64_char {{ v += base64_char }}
+ base64_char {{ v += base64_char }}
+ base64_char {{ v += base64_char }}
+ base64_char {{ v += base64_char }}
{{ return v }}
rule base64_terminal: {{ v = '' }}
Added: imaplib/head/runtests.py
==============================================================================
--- imaplib/head/runtests.py 2003-07-16 14:29:59 UTC (rev 491)
+++ imaplib/head/runtests.py 2003-07-16 16:02:46 UTC (rev 492)
@@ -0,0 +1,53 @@
+#!/usr/bin/python2.2
+# Python-based gopher server
+# Module: main test runner
+# COPYRIGHT #
+# Copyright (C) 2002 John Goerzen
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# END OF COPYRIGHT #
+
+import sys, profile
+# sys.path.insert("-1", "..")
+
+import unittest
+from pygopherd import *
+import pygopherd.protocols
+import pygopherd.protocols.ProtocolMultiplexerTest
+import pygopherd.protocols.baseTest
+import pygopherd.protocols.rfc1436Test
+import pygopherd.protocols
+import pygopherd.handlers.ZIP
+
+def suite():
+ tests = [initializationTest,
+ GopherExceptionsTest,
+ fileextTest,
+ gopherentryTest,
+ loggerTest,
+ pipeTest,
+ pygopherd.protocols.ProtocolMultiplexerTest,
+ pygopherd.protocols.baseTest,
+ pygopherd.protocols.rfc1436Test,
+ pygopherd.handlers.ZIP
+ ]
+ suite = unittest.TestSuite()
+ for module in tests:
+ suite.addTest(unittest.findTestCases(module))
+ return suite
+
+if __name__ == '__main__':
+ profile.run("unittest.main(defaultTest='suite')", 'profile.out')
+# unittest.main(defaultTest='suite')
+
Added: imaplib/head/runtestsgui.py
==============================================================================
--- imaplib/head/runtestsgui.py 2003-07-16 14:29:59 UTC (rev 491)
+++ imaplib/head/runtestsgui.py 2003-07-16 16:02:46 UTC (rev 492)
@@ -0,0 +1,20 @@
+#!/usr/bin/python2.2
+# COPYRIGHT #
+# Copyright (C) 2002 John Goerzen
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# END OF COPYRIGHT #
+
+import unittestgui
+unittestgui.main('runtests.suite')