473,387 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Sorting attributes by catagory


This is for a new version of pydoc if I can get the class attributes sorted
out. The module level attributes aren't too difficult to categorize.

(I might be just too tired to see the obvious.)

The original pydoc did this a somewhat round about way, so I would like to
find a more direct method if possible.
Where dir(obj) is used to get all attributes of a module or class. And
they are then sorted into categories depending on what they are.

(In order of precedence.)

For modules:

- imported_items (defined in another module,
or is another module)
- classes
- functions
- other_objects (everything else)
For classes:

- from_else_where (object created someplace else)
- inherited_attributes (from parents classes or type)
- static_methods_here
- class_methods_here
- other_methods
- properties
- getset_descriptors
- other_descriptors
- other_attributes (everything else)
A single function that accepts an object and can return one of the above
(or equivalent) strings would be ideal. Finer grained categorizing is ok
as long as they don't overlap more than one group.

It seems I can get some of these fairly easy with the inspect module, but
others I need to test in multiple ways.

Any ideas?
Cheers,
Ron

May 9 '07 #1
4 1444
On May 9, 11:32 am, Ron Adam <r...@ronadam.comwrote:
This is for a new version of pydoc if I can get the class attributes sorted
out. The module level attributes aren't too difficult to categorize.

(I might be just too tired to see the obvious.)

The original pydoc did this a somewhat round about way, so I would like to
find a more direct method if possible.

Where dir(obj) is used to get all attributes of a module or class. And
they are then sorted into categories depending on what they are.

(In order of precedence.)

For modules:

- imported_items (defined in another module,
or is another module)
- classes
- functions
- other_objects (everything else)

For classes:

- from_else_where (object created someplace else)
- inherited_attributes (from parents classes or type)
- static_methods_here
- class_methods_here
- other_methods
- properties
- getset_descriptors
- other_descriptors
- other_attributes (everything else)

A single function that accepts an object and can return one of the above
(or equivalent) strings would be ideal. Finer grained categorizing is ok
as long as they don't overlap more than one group.

It seems I can get some of these fairly easy with the inspect module, but
others I need to test in multiple ways.

Any ideas?

Cheers,
Ron
Ron,

Consider using epydoc if you can. Epydoc will sort the methods and it
will also let you use custom CSS style sheets for the final HTML
output. Check out the documentation of my PyDBTable module.
http://www.psipy.com/PyDBTable

-Nick Vatamaniuc
May 10 '07 #2
Nick Vatamaniuc wrote:
Ron,

Consider using epydoc if you can. Epydoc will sort the methods and it
will also let you use custom CSS style sheets for the final HTML
output. Check out the documentation of my PyDBTable module.
http://www.psipy.com/PyDBTable

-Nick Vatamaniuc

Hi Nick,

I already have sorting and style sheets taken care of. I'm just trying to
get the content of each sub section correct at this point. The overall
frame work is finished.

I don't think Epydoc can replace the console help() output. The site.py
module imports help(), from pydoc.py. That serves as the consoles
interactive help mode. When you type help() at the console, you are using
pydoc.

Some of the differences...

Epydoc
------
Output formats:
- html files
- graphs (requires Graphviz) I like this!
- pdf files (requires latex)

* Requires explicitly generating files first.
* Supports file parsing only instead of introspection.

Epydoc is more of a complete application and has many nice features such as
the graphs and completeness checks, that will make it better than pydoc for
creating more complete pre-generated html documents with less work.

Pydoc
=====
Output formats:
- live interactive console text
- live interactive html with a local html server.
* no files are generated. (just in the browser cache)
* supports custom CSS stylesheets

(API data output...)
- text
- html page
- html section (for use in templates)
- xml
- reST (not yet, but will be easy to do)

The reason for having additional output formats is it makes it much easier
to use it as a tool to extract documentation from source code to be
combined with existing more complete documentation.

I am planning on writing output formatters to return docutils and docbook
data structures as well. With those, you will be able to convert to latex,
pdf, and other formats. The data formats for those are very close to what
I'm using, so this should be easy to do.

Other side benefits of doing this is that some of the modules in pydoc have
been generalized so that they can be used without pydoc. The html server,
and the document data and formatter classes, can be used independently of
pydoc.

The overall total size has not increased much, and it is more modular,
maintainable, and extendable. Maintainability is a major concern for any
library module or package.

Of course it will need to be approved first. ;-)

Cheers,
Ron


May 10 '07 #3
On May 10, 1:28 am, Ron Adam <r...@ronadam.comwrote:
Nick Vatamaniuc wrote:
Ron,
Consider using epydoc if you can. Epydoc will sort the methods and it
will also let you use custom CSS style sheets for the final HTML
output. Check out the documentation of my PyDBTable module.
http://www.psipy.com/PyDBTable
-Nick Vatamaniuc

Hi Nick,

I already have sorting and style sheets taken care of. I'm just trying to
get the content of each sub section correct at this point. The overall
frame work is finished.

I don't think Epydoc can replace the console help() output. The site.py
module imports help(), from pydoc.py. That serves as the consoles
interactive help mode. When you type help() at the console, you are using
pydoc.

Some of the differences...

Epydoc
------
Output formats:
- html files
- graphs (requires Graphviz) I like this!
- pdf files (requires latex)

* Requires explicitly generating files first.
* Supports file parsing only instead of introspection.

Epydoc is more of a complete application and has many nice features such as
the graphs and completeness checks, that will make it better than pydoc for
creating more complete pre-generated html documents with less work.

Pydoc
=====
Output formats:
- live interactive console text
- live interactive html with a local html server.
* no files are generated. (just in the browser cache)
* supports custom CSS stylesheets

(API data output...)
- text
- html page
- html section (for use in templates)
- xml
- reST (not yet, but will be easy to do)

The reason for having additional output formats is it makes it much easier
to use it as a tool to extract documentation from source code to be
combined with existing more complete documentation.

I am planning on writing output formatters to return docutils and docbook
data structures as well. With those, you will be able to convert to latex,
pdf, and other formats. The data formats for those are very close to what
I'm using, so this should be easy to do.

Other side benefits of doing this is that some of the modules in pydoc have
been generalized so that they can be used without pydoc. The html server,
and the document data and formatter classes, can be used independently of
pydoc.

The overall total size has not increased much, and it is more modular,
maintainable, and extendable. Maintainability is a major concern for any
library module or package.

Of course it will need to be approved first. ;-)

Cheers,
Ron
Thanks for the info, Ron. I had no idea pydoc was that powerful!
-Nick

May 10 '07 #4
Nick Vatamaniuc wrote:
Thanks for the info, Ron. I had no idea pydoc was that powerful!
-Nick
Change *was* to *will be*.

It really needed to be re factored. ;-)
Cheers,
Ron

May 10 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Pratyush | last post by:
Hi, Suppose there is a vector of objects of class A, i.e., std::vector<A> vec_A(N); The class A satisifies all the STL vector requirements. Now I wish to add some attributes for each of the...
4
by: Gareth Gale | last post by:
I'm trying to implement a way of allowing a user to sort a HTML table via Javascript on the client. I've seen lots of samples where single column sorting (asc or desc) is shown, but I'd like nested...
1
by: xrow | last post by:
Hello I have a simple webservice / c# application that receives data from server and prints the data in the asp:datagrid control I have problem when sorting data in datagrid I have created...
0
by: Eric | last post by:
Hello, I have a datagrid with sorting enabled. When clickong on the colum names in the header the datagrid is sorted no problem. Unfortunatly, I have a graph that needs to be generated for each...
8
by: Matthew Curiale | last post by:
I am creating an app that lists clients of a company for management of different attributes for that company. The first page is a listing of the companies currently in the database. I have my...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
7
by: Cerebrus99 | last post by:
Hi all, I am confused about how to sort an XML file. I mean how to *actually* sort the data in the physical file, not how to display sorted data. I am using a large XML file as a back-end...
7
by: bstieve | last post by:
Hi all, i'm looking at the next problem. i'm trying to get the names of attributes of object or of types. example class test private name as string sub new (byval test as string) me.name =...
0
by: cdelautour | last post by:
Hi there, I am currently working with the property grid and I am implementing an indexed category system (sorts categories via index before alphabetically). I should say that at this point my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.