~ubuntu-branches/ubuntu/wily/luatex/wily

« back to all changes in this revision

Viewing changes to source/libs/zziplib/zziplib-0.13.58/docs/zzipdoc/functionprototype.py

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2010-04-29 00:47:19 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100429004719-o42etkqe90n97b9e
Tags: 0.60.1-1
* new upstream release, adapt build-script patch
* disable patch: upstream-epstopdf_cc_no_xpdf_patching, included upstream
* disable patch: libpoppler-0.12, not needed anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from match import Match
 
2
 
 
3
class FunctionPrototype:
 
4
    """ takes a single function prototype line (cut from some source file)
 
5
    and parses it into the relevant portions 'prespec', 'namespec' and
 
6
    'callspec'. Additionally we present 'name' from the namespec that is
 
7
    usually used as the filename stem for a manual page """
 
8
    def __init__(self, functionheader = None):
 
9
        self.functionheader = functionheader
 
10
        self.prespec = None
 
11
        self.namespec = None
 
12
        self.callspec = None
 
13
        self.name = None
 
14
    def get_functionheader(self):
 
15
        return self.functionheader
 
16
    def get_prototype(self):
 
17
        if self.functionheader is None:
 
18
            return None
 
19
        return self.functionheader.get_prototype()
 
20
    def get_filename(self):
 
21
        if self.functionheader is None:
 
22
            return None
 
23
        return self.functionheader.get_filename()
 
24
    def parse(self, functionheader = None):
 
25
        if functionheader is not None:
 
26
            self.functionheader = functionheader
 
27
        if self.functionheader is None:
 
28
            return False
 
29
        found = Match()
 
30
        prototype = self.get_prototype()
 
31
        if prototype & found(r"(?s)^(.*[^.])"
 
32
                             r"\b(\w[\w.]*\w)\b"
 
33
                             r"(\s*\(.*)$"):
 
34
            self.prespec = found.group(1).lstrip()
 
35
            self.namespec = found.group(2)
 
36
            self.callspec = found.group(3).lstrip()
 
37
            self.name = self.namespec.strip()
 
38
            return True
 
39
        return False
 
40
    def _assert_parsed(self):
 
41
        if self.name is None:
 
42
            return self.parse()
 
43
        return True
 
44
    def get_prespec(self):
 
45
        if not self._assert_parsed(): return None
 
46
        return self.prespec
 
47
    def get_namespec(self):
 
48
        if not self._assert_parsed(): return None
 
49
        return self.namespec
 
50
    def get_callspec(self):
 
51
        if not self._assert_parsed(): return None
 
52
        return self.callspec
 
53
    def get_name(self):
 
54
        if not self._assert_parsed(): return None
 
55
        return self.name
 
56
    def xml_text(self):
 
57
        if not self.namespec: return self.namespec
 
58
        return ("<fu:protospec><fu:prespec>"+self.prespec+"</fu:prespec>"+
 
59
                "<fu:namespec>"+self.namespec+"</fu:namespec>"+
 
60
                "<fu:callspec>"+self.callspec+"</fu:callspec></fu:protospec>")