Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes
distutils.command.check.check Class Reference
Inheritance diagram for distutils.command.check.check:
Inheritance graph
[legend]
Collaboration diagram for distutils.command.check.check:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def initialize_options
def finalize_options
def warn
def run
def check_metadata
def check_restructuredtext

Public Attributes

 restructuredtext
 metadata
 strict

Static Public Attributes

tuple description = ("perform some checks on the package")
list user_options
list boolean_options = ['metadata', 'restructuredtext', 'strict']

Private Member Functions

def _check_rst_data

Private Attributes

 _warnings

Detailed Description

This command checks the meta-data of the package.

Definition at line 33 of file check.py.


Member Function Documentation

def distutils.command.check.check._check_rst_data (   self,
  data 
) [private]
Returns warnings when the provided data doesn't compile.

Definition at line 118 of file check.py.

00118 
00119     def _check_rst_data(self, data):
00120         """Returns warnings when the provided data doesn't compile."""
00121         source_path = StringIO()
00122         parser = Parser()
00123         settings = frontend.OptionParser().get_default_values()
00124         settings.tab_width = 4
00125         settings.pep_references = None
00126         settings.rfc_references = None
00127         reporter = SilentReporter(source_path,
00128                           settings.report_level,
00129                           settings.halt_level,
00130                           stream=settings.warning_stream,
00131                           debug=settings.debug,
00132                           encoding=settings.error_encoding,
00133                           error_handler=settings.error_encoding_error_handler)
00134 
00135         document = nodes.document(settings, reporter, source=source_path)
00136         document.note_source(source_path, -1)
00137         try:
00138             parser.parse(data, document)
00139         except AttributeError:
00140             reporter.messages.append((-1, 'Could not finish the parsing.',
00141                                       '', {}))
00142 
00143         return reporter.messages

Here is the caller graph for this function:

Ensures that all required elements of meta-data are supplied.

name, version, URL, (author and author_email) or
(maintainer and maintainer_email)).

Warns if any are missing.

Definition at line 77 of file check.py.

00077 
00078     def check_metadata(self):
00079         """Ensures that all required elements of meta-data are supplied.
00080 
00081         name, version, URL, (author and author_email) or
00082         (maintainer and maintainer_email)).
00083 
00084         Warns if any are missing.
00085         """
00086         metadata = self.distribution.metadata
00087 
00088         missing = []
00089         for attr in ('name', 'version', 'url'):
00090             if not (hasattr(metadata, attr) and getattr(metadata, attr)):
00091                 missing.append(attr)
00092 
00093         if missing:
00094             self.warn("missing required meta-data: %s"  % ', '.join(missing))
00095         if metadata.author:
00096             if not metadata.author_email:
00097                 self.warn("missing meta-data: if 'author' supplied, " +
00098                           "'author_email' must be supplied too")
00099         elif metadata.maintainer:
00100             if not metadata.maintainer_email:
00101                 self.warn("missing meta-data: if 'maintainer' supplied, " +
00102                           "'maintainer_email' must be supplied too")
00103         else:
00104             self.warn("missing meta-data: either (author and author_email) " +
00105                       "or (maintainer and maintainer_email) " +
00106                       "must be supplied")

Here is the call graph for this function:

Here is the caller graph for this function:

Checks if the long string fields are reST-compliant.

Definition at line 107 of file check.py.

00107 
00108     def check_restructuredtext(self):
00109         """Checks if the long string fields are reST-compliant."""
00110         data = self.distribution.get_long_description()
00111         for warning in self._check_rst_data(data):
00112             line = warning[-1].get('line')
00113             if line is None:
00114                 warning = warning[1]
00115             else:
00116                 warning = '%s (line %s)' % (warning[1], line)
00117             self.warn(warning)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 53 of file check.py.

00053 
00054     def finalize_options(self):
00055         pass

Here is the caller graph for this function:

Sets default values for options.

Definition at line 46 of file check.py.

00046 
00047     def initialize_options(self):
00048         """Sets default values for options."""
00049         self.restructuredtext = 0
00050         self.metadata = 1
00051         self.strict = 0
00052         self._warnings = 0

Runs the command.

Definition at line 61 of file check.py.

00061 
00062     def run(self):
00063         """Runs the command."""
00064         # perform the various tests
00065         if self.metadata:
00066             self.check_metadata()
00067         if self.restructuredtext:
00068             if HAS_DOCUTILS:
00069                 self.check_restructuredtext()
00070             elif self.strict:
00071                 raise DistutilsSetupError('The docutils package is needed.')
00072 
00073         # let's raise an error in strict mode, if we have at least
00074         # one warning
00075         if self.strict and self._warnings > 0:
00076             raise DistutilsSetupError('Please correct your package.')

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.command.check.check.warn (   self,
  msg 
)
Counts the number of warnings that occurs.

Definition at line 56 of file check.py.

00056 
00057     def warn(self, msg):
00058         """Counts the number of warnings that occurs."""
00059         self._warnings += 1
00060         return Command.warn(self, msg)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 51 of file check.py.

Definition at line 44 of file check.py.

tuple distutils.command.check.check.description = ("perform some checks on the package") [static]

Definition at line 36 of file check.py.

Definition at line 49 of file check.py.

Definition at line 48 of file check.py.

Definition at line 50 of file check.py.

Initial value:
[('metadata', 'm', 'Verify meta-data'),
                    ('restructuredtext', 'r',
                     ('Checks if long string meta-data syntax '
                      'are reStructuredText-compliant')),
                    ('strict', 's',
                     'Will exit with an error if a check fails')]

Definition at line 37 of file check.py.


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