Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
MoinMoin.wikisync.SyncPage Class Reference

List of all members.

Public Member Functions

def __init__
def __repr__
def __unicode__
def __lt__
def __hash__
def __eq__
def add_missing_pagename
def filter
def merge
def is_only_local
def is_only_remote
def is_local_and_remote

Public Attributes

 name
 local_rev
 remote_rev
 local_name
 remote_name
 local_deleted
 remote_deleted
 local_mime_type
 remote_mime_type

Static Public Attributes

tuple filter = classmethod(filter)
tuple merge = classmethod(merge)

Detailed Description

This class represents a page in one or two wiki(s). 

Definition at line 46 of file wikisync.py.


Constructor & Destructor Documentation

def MoinMoin.wikisync.SyncPage.__init__ (   self,
  name,
  local_rev = None,
  remote_rev = None,
  local_name = None,
  remote_name = None,
  local_deleted = False,
  remote_deleted = False 
)
Creates a SyncPage instance.
    @param name: The canonical name of the page, without prefixes.
    @param local_rev: The revision of the page in the local wiki.
    @param remote_rev: The revision of the page in the remote wiki.
    @param local_name: The page name of the page in the local wiki.
    @param remote_name: The page name of the page in the remote wiki.

Definition at line 49 of file wikisync.py.

00049 
00050                  local_deleted=False, remote_deleted=False):
00051         """ Creates a SyncPage instance.
00052             @param name: The canonical name of the page, without prefixes.
00053             @param local_rev: The revision of the page in the local wiki.
00054             @param remote_rev: The revision of the page in the remote wiki.
00055             @param local_name: The page name of the page in the local wiki.
00056             @param remote_name: The page name of the page in the remote wiki.
00057         """
00058         self.name = name
00059         self.local_rev = local_rev
00060         self.remote_rev = remote_rev
00061         self.local_name = local_name
00062         self.remote_name = remote_name
00063         assert local_rev or remote_rev
00064         assert local_name or remote_name
00065         self.local_deleted = local_deleted
00066         self.remote_deleted = remote_deleted
00067         self.local_mime_type = MIMETYPE_MOIN   # XXX no usable storage API yet
00068         self.remote_mime_type = MIMETYPE_MOIN
00069         assert remote_rev != 99999999


Member Function Documentation

def MoinMoin.wikisync.SyncPage.__eq__ (   self,
  other 
)

Definition at line 83 of file wikisync.py.

00083 
00084     def __eq__(self, other):
00085         if not isinstance(other, SyncPage):
00086             return False
00087         return self.name == other.name

Ensures that the hash value of this page only depends on the canonical name. 

Definition at line 79 of file wikisync.py.

00079 
00080     def __hash__(self):
00081         """ Ensures that the hash value of this page only depends on the canonical name. """
00082         return hash(self.name)

def MoinMoin.wikisync.SyncPage.__lt__ (   self,
  other 
)

Definition at line 76 of file wikisync.py.

00076 
00077     def __lt__(self, other):
00078         return self.name < other.name

Definition at line 70 of file wikisync.py.

00070 
00071     def __repr__(self):
00072         return repr("<Sync Page %r>" % unicode(self))

Definition at line 73 of file wikisync.py.

00073 
00074     def __unicode__(self):
00075         return u"%s[%s|%s]<%r:%r>" % (self.name, self.local_name, self.remote_name, self.local_rev, self.remote_rev)

def MoinMoin.wikisync.SyncPage.add_missing_pagename (   self,
  local,
  remote 
)
Checks if the particular concrete page names are unknown and fills
    them in.

Definition at line 88 of file wikisync.py.

00088 
00089     def add_missing_pagename(self, local, remote):
00090         """ Checks if the particular concrete page names are unknown and fills
00091             them in.
00092         """
00093         if self.local_name is None:
00094             n_name = normalise_pagename(self.remote_name, remote.prefix)
00095             assert n_name is not None
00096             self.local_name = (local.prefix or "") + n_name
00097         elif self.remote_name is None:
00098             n_name = normalise_pagename(self.local_name, local.prefix)
00099             assert n_name is not None
00100             self.remote_name = (remote.prefix or "") + n_name
00101 
00102         return self # makes using list comps easier

Here is the call graph for this function:

def MoinMoin.wikisync.SyncPage.filter (   cls,
  sp_list,
  func 
)
Returns all pages in sp_list that let func return True
    for the canonical page name.

Definition at line 103 of file wikisync.py.

00103 
00104     def filter(cls, sp_list, func):
00105         """ Returns all pages in sp_list that let func return True
00106             for the canonical page name.
00107         """
        return [x for x in sp_list if func(x.name)]
Is true if the page is in both wikis. 

Definition at line 133 of file wikisync.py.

00133 
00134     def is_local_and_remote(self):
00135         """ Is true if the page is in both wikis. """
00136         return self.local_rev and self.remote_rev
00137 

Is true if the page is only in the local wiki. 

Definition at line 125 of file wikisync.py.

00125 
00126     def is_only_local(self):
00127         """ Is true if the page is only in the local wiki. """
00128         return not self.remote_rev

Is true if the page is only in the remote wiki. 

Definition at line 129 of file wikisync.py.

00129 
00130     def is_only_remote(self):
00131         """ Is true if the page is only in the remote wiki. """
00132         return not self.local_rev

def MoinMoin.wikisync.SyncPage.merge (   cls,
  local_list,
  remote_list 
)
Merges two lists of SyncPages into one, migrating attributes like the names. 

Definition at line 110 of file wikisync.py.

00110 
00111     def merge(cls, local_list, remote_list):
00112         """ Merges two lists of SyncPages into one, migrating attributes like the names. """
00113         # map page names to SyncPage objects :-)
00114         d = dict(zip(local_list, local_list))
00115         for sp in remote_list:
00116             if sp in d:
00117                 d[sp].remote_rev = sp.remote_rev
00118                 d[sp].remote_name = sp.remote_name
00119                 d[sp].remote_deleted = sp.remote_deleted
00120                 # XXX merge mime type here
00121             else:
00122                 d[sp] = sp
        return d.keys()

Member Data Documentation

tuple MoinMoin.wikisync.SyncPage.filter = classmethod(filter) [static]

Definition at line 108 of file wikisync.py.

Definition at line 64 of file wikisync.py.

Definition at line 66 of file wikisync.py.

Definition at line 60 of file wikisync.py.

Definition at line 58 of file wikisync.py.

tuple MoinMoin.wikisync.SyncPage.merge = classmethod(merge) [static]

Definition at line 123 of file wikisync.py.

Definition at line 57 of file wikisync.py.

Definition at line 65 of file wikisync.py.

Definition at line 67 of file wikisync.py.

Definition at line 61 of file wikisync.py.

Definition at line 59 of file wikisync.py.


The documentation for this class was generated from the following file: