[Python-checkins] CVS: python/nondist/sandbox/typecheck/lib ntpath.pyt,NONE,1.1 os.pyt,NONE,1.1 sre.pyt,NONE,1.1 xmllib.pyt,NONE,1.1

Paul Prescod prescod@users.sourceforge.net
Mon, 19 Mar 2001 19:01:03 -0800


Update of /cvsroot/python/python/nondist/sandbox/typecheck/lib
In directory usw-pr-cvs1:/tmp/cvs-serv29621/lib

Added Files:
	ntpath.pyt os.pyt sre.pyt xmllib.pyt 
Log Message:
First drop of experimental type checker.


--- NEW FILE: ntpath.pyt ---
__declare__("""
def normcase(s: String) -> path: String

def isabs(s: String) -> isabs: StrictBoolean

def join(a: String, *p: Sequence(String)) -> path: String

def splitdrive(p: String) -> (drivespec: String, pathspec: String)

def splitunc(p: String)  -> (unc: String, res: String)

def split(p: String) -> (head: String, tail: String)

def splitext(p: String) -> (root: String, ext: String)

def basename(p: String) -> base: String

def dirname(p: String) -> head: String

def commonprefix(m: Sequence(String)) -> prefix: String

def getsize(filename: String) -> size: Int

def getmtime(filename: String) -> ticks: Int

def getatime(path: String) -> ticks: Int

def islink(filename: String) -> link: StrictBoolean

def exists(path: String) -> exists: StrictBoolean

def isdir(path: String) -> dir: StrictBoolean

def isfile(filename: String) -> isfile: StrictBoolean

def ismount(path: String) -> ismount: StrictBoolean

def walk(top: String, func: Callable, arg ) -> None

def expanduser(path: String) -> expanded: String

def expandvars(path: String) -> expanded: String

def normpath(path: String) -> normalized: String

def abspath(path: String) -> normalized: String
""")

--- NEW FILE: os.pyt ---
WaitNoWait = Interface("WaitNoWait", 
                "Wait or don't wait", None, StrictBoolean)

__declare__("""
def makedirs(name: String, mode: Int)
def removedirs(name: String)
def renames(old: String, new: String)
def execl(file: String, args: Sequence(String))
def execle(file: String, args: Sequence(String))
def execlp(file: String, args: Sequence(String))
def execlpe(file: String, args: Sequence(String))
def execvpe(file: String, args: Sequence(String), env: Mapping)
def _Environ.__init__(self, environ: Mapping)
def _Environ.__setitem__(self, key: String, item: String)
def _Environ.__getitem__(self, key: String) -> String
def _Environ.__delitem__(self, key: String)
def _Environ.has_key(self, key: String) -> StrictBoolean
def _Environ.get(self, key: String, failObj) -> String
def _Environ.update(self, dict: Mapping)
def getenv(key: String, default ) -> String
def spawnv(mode: WaitNoWait, file: String, args: Sequence(String) ) -> rc: Int
def spawnve(mode: WaitNoWait, file: String, 
                    args: Sequence, env: Mapping(String, String) ) -> rc: Int
def spawnvp(mode: WaitNoWait, file: String, args: Sequence)-> rc: Int
def spawnvpe(mode: WaitNoWait, file: String, 
                    args: Sequence, env: Mapping)-> rc: Int
def spawnl(mode: WaitNoWait, file: String, args: Sequence)-> rc: Int
def spawnlp(mode: WaitNoWait, file: String, args: Sequence)-> rc: Int
def spawnle(mode: WaitNoWait, file: String, 
                env: Mapping, args: Sequence)-> rc: Int
def spawnlpe(mode: WaitNoWait, file: String, 
                env: Mapping, args: Sequence)-> rc: Int
def popen2(cmd: String, mode: String, bufsize, Int) 
                    -> (stdin: ReadStream, stdout: WriteStream)
def popen3(cmd: String, mode: String, bufsize, Int) 
            -> (stdin: ReadStream, stdout: WriteStream, stderr: WriteStream)
def popen4(cmd: String, mode: String, bufsize, Int) 
                    -> (stdin: ReadStream, stdout: WriteStream)
""")

# spawn*'s signatures are a little funny. The comments in the code
# seem just wrong.

# XXX many of these will not be checked on platforms where the
# functions are actually built-in to the C library.

--- NEW FILE: sre.pyt ---
from typecheck import Interface, __declare__

# should do better interfaces for these
Match = Interface("Match", "Regular expression match", 
                    lambda obj: hasattr(obj, "group"))

Regex = Interface("Regex", "Regular expression object",
                    lambda obj: hasattr(obj, "match"))

__declare__("""
def compile(pattern: String, flags: Int) 
            -> compiled_re: Regex

def match(pattern: String, string: String,  flags: Int) 
                    -> match : (Match | None)

def search(pattern: String, string: String, flags: Int)
                    -> match : (Match | None)

def split(pattern: String, string: String, maxsplit: Int)
                    -> value: Sequence((String | None))

def findall(pattern: String, string: String) 
                -> value: Sequence

def sub(pattern: String, 
        repl: (String|Callable),
        string: String, count: Int) -> rc: String

def subn(pattern: String, repl: String, count: Int) 
                -> (new_string: String, number_of_subs_made: Int)

def escape(pattern: String) -> escaped_string: String
""")


--- NEW FILE: xmllib.pyt ---
from typecheck import __declare__
from  sre import Match

__declare__("""

# xmllib has a funny way of doing its init...
#def XMLParser.__init__(self, 
#            accept_unquoted_attributes: StrictBoolean,
#            accept_missing_endtag_name: StrictBoolean,
#            map_case: StrictBoolean,
#            accept_utf8: String,
#            translate_attribute_references: StrictBoolean )

def XMLParser.reset(self) -> rc: None

def XMLParser.setnomoretags(self) -> rc: None

def XMLParser.setliteral(self) -> rc: None

def XMLParser.feed(self, data: String) -> rc: None

def XMLParser.close(self) -> rc: None

def XMLParser.translate_references(self, 
            data:String, all: StrictBoolean) 
                -> unknown: (String | None)

def XMLParser.getnamespace(self) -> namespace: Mapping

def XMLParser.goahead(self, end: StrictBoolean) -> rc: None

def XMLParser.parse_comment(self, i: Int) -> length_or_no_end : Int

def XMLParser.parse_doctype(self, res: Match) -> length_or_no_end : Int

def XMLParser.parse_cdata(self, i: Int) -> length_or_no_end : Int

def XMLparser.parse_starttag(self, i: Int) -> length_or_no_end : Int

def XMLParser.parse_endtag(self, i: Int) -> length_or_no_end : Int

def XMLParser.finish_starttag(self, tagname: String,
                attrdict: Mapping, method: (Callable | None) )
         -> length_or_no_end : Int

def XMLParser.finish_endtag(self, tag: String) -> rc: None

def XMLParser.handle_charref(self, name: String) -> rc: None


 

def XMLparser.parse_proc(self, i: Int) -> length_or_no_end : Int

def XMLParser.parse_attributes(self, tag: String, 
                                i: Int, j: Int) 
                -> (attrdict: Mapping, namespace: Mapping, i: Int)
                    
""")