Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Entry Class Reference

Public Member Functions

def __init__
 
def __str__
 
def applies_to
 
def allowance
 

Data Fields

 useragents
 
 rulelines
 

Detailed Description

An entry has one or more user-agents and zero or more rulelines

Definition at line 160 of file robotparser.py.

Constructor & Destructor Documentation

def __init__ (   self)

Definition at line 162 of file robotparser.py.

163  def __init__(self):
164  self.useragents = []
165  self.rulelines = []

Member Function Documentation

def __str__ (   self)

Definition at line 166 of file robotparser.py.

References Entry.rulelines, locale.str(), and Entry.useragents.

167  def __str__(self):
168  ret = ""
169  for agent in self.useragents:
170  ret = ret + "User-agent: "+agent+"\n"
171  for line in self.rulelines:
172  ret = ret + str(line) + "\n"
173  return ret
def allowance (   self,
  filename 
)
Preconditions:
- our agent applies to this entry
- filename is URL decoded

Definition at line 188 of file robotparser.py.

References Entry.rulelines, and locale.str().

189  def allowance(self, filename):
190  """Preconditions:
191  - our agent applies to this entry
192  - filename is URL decoded"""
193  for line in self.rulelines:
194  _debug((filename, str(line), line.allowance))
195  if line.applies_to(filename):
196  return line.allowance
197  return 1
def applies_to (   self,
  useragent 
)
check if this entry applies to the specified agent

Definition at line 174 of file robotparser.py.

References string.lower(), and Entry.useragents.

175  def applies_to(self, useragent):
176  """check if this entry applies to the specified agent"""
177  # split the name token and make it lower case
178  useragent = useragent.split("/")[0].lower()
179  for agent in self.useragents:
180  if agent=='*':
181  # we have the catch-all agent
182  return 1
183  agent = agent.lower()
184  # don't forget to re.escape
185  if re.search(re.escape(useragent), agent):
186  return 1
187  return 0

Field Documentation

rulelines

Definition at line 164 of file robotparser.py.

useragents

Definition at line 163 of file robotparser.py.


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