pax_global_header00006660000000000000000000000064145704015370014520gustar00rootroot0000000000000052 comment=272c4fb584ecffd3623d1c15e83dee023b52e807 pybugz-0.14/000077500000000000000000000000001457040153700127645ustar00rootroot00000000000000pybugz-0.14/LICENSE000066400000000000000000000431331457040153700137750ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. pybugz-0.14/README000066400000000000000000000070051457040153700136460ustar00rootroot00000000000000PyBugz - Python Bugzilla Interface ---------------------------------- Bugzilla has a very inefficient user interface, so I've written a command line utility to interact with it. This is mainly done to help me with closing bugs on Gentoo Bugzilla by grabbing patches, ebuilds and so on. Author ------ Alastair Tse . Copyright (c) 2006 under GPL-2. Requirements ------------ * Python 3.3 or later Features -------- * Searching bugzilla * Listing details of a bug including comments and attachments * Downloading/viewing attachments from bugzilla * Posting bugs, comments, and making changes to an existing bug. * Adding attachments to a bug. Usage/Workflow -------------- PyBugz comes with a command line interface called "bugz". It's operation is similar in style to cvs/svn where a subcommand is required for operation. To explain how it works, I will use a typical workflow for Gentoo development. 1) Searching bugzilla for bugs I can fix, I'll run the command: --------------------------------------------------------------- $ bugz search "version bump" --assigned-to liquidx@gentoo.org * Using https://bugs.gentoo.org/xmlrpc.cgi * Searching for "version bump" 101968 liquidx net-im/msnlib version bump 125468 liquidx version bump for dev-libs/g-wrap-1.9.6 130608 liquidx app-dicts/stardict version bump: 2.4.7 2) Narrow down on bug #101968, I can execute: --------------------------------------------- $ bugz get 101968 * Using https://bugs.gentoo.org/xmlrpc.cgi * Getting bug 130608 .. Title : app-dicts/stardict version bump: 2.4.7 Assignee : liquidx@gentoo.org Reported : 2006-04-20 07:36 PST Updated : 2006-05-29 23:18:12 PST Status : NEW URL : http://stardict.sf.net Severity : enhancement Reporter : dushistov@mail.ru Priority : P2 Comments : 3 Attachments : 1 [ATTACH] [87844] [stardict 2.4.7 ebuild] [Comment #1] dushistov@----.ru : 2006-04-20 07:36 PST ... 3) Now this bug has an attachment submitted by the user, so I can easily pull that attachment in: ----------------------------------------------------------------- $ bugz attachment 87844 * Using https://bugs.gentoo.org/xmlrpc.cgi * Getting attachment 87844 * Saving attachment: "stardict-2.4.7.ebuild" 4) If the ebuild is suitable, we can commit it using our normal repoman tools, and close the bug. --------------------------------------------------------------- $ bugz modify 130608 --fixed -c "Thanks for the ebuild. Committed to portage" or if we find that the bug is invalid, we can close it by using: $ bugz modify 130608 --invalid -c "Not reproducable" Other options ------------- bugz has an extensive help system for commands and options. bugz --help gives help for the global options and subcommands, and bugz --help gives help for that specific subcommand. PyBugz Configuration -------------------- PyBugz supports a configuration system which defines defaults for multiple Bugzilla installations and allows the system administrator and individual users to override or add to these settings. The supplied defaults are stored in /usr/share/pybugz.d/*.conf. The system administrator can override or add to these defaults on a site-wide basis by creating a directory /etc/pybugz.d and adding files with a .conf extension to this directory. Individual users can override or add to all of these settings by placing a file named .bugzrc in their home directory. For more information about this configuration system, see the pybugz.d (5) man page. pybugz-0.14/bugz/000077500000000000000000000000001457040153700137335ustar00rootroot00000000000000pybugz-0.14/bugz/__init__.py000066400000000000000000000002411457040153700160410ustar00rootroot00000000000000__version__ = '0.14' __license__ = """Copyright (c) 2006, Alastair Tse, All rights reserved. This following source code is licensed under the GPL v2 License.""" pybugz-0.14/bugz/cli.py000066400000000000000000000602651457040153700150650ustar00rootroot00000000000000""" Python Bugzilla Interface Simple command-line interface to bugzilla to allow: - searching - getting bug info - saving attachments Requirements ------------ - Python 3.3 or later Classes ------- - BugzillaProxy - Server proxy for communication with Bugzilla """ import getpass import os import re import subprocess import sys import textwrap import xmlrpc.client from bugz.cli_argparser import make_arg_parser from bugz.configfile import load_config from bugz.settings import Settings from bugz.exceptions import BugzError from bugz.log import log_error, log_info from bugz.utils import block_edit, get_content_type def check_bugz_token(): tokenFound = os.path.isfile(os.path.expanduser('~/.bugz_token')) or \ os.path.isfile(os.path.expanduser('~/.bugz_tokens')) if not tokenFound: return print('This version of pybugz no longer supports tokens.') print() print('If the bugzilla you are accessing is 5.0 or newer, you can') print('generate an api key by visiting the preferences section') print('of the Bugzilla web interface.') print('For bugzilla 3.6 or newer, you can use your username and password') print() print('Once you have decided how you want to authenticate,') print('please configure the appropriate settings in ~/.bugzrc') print('and remove ~/.bugz_token and ~/.bugz_tokens') print() print('see man pybugz.d for ~/.bugzrc settings') print('This decision was made because Bugzilla is deprecating tokens.') def check_auth(settings): """Authenticate a session. """ if settings.skip_auth: for x in ['key', 'user', 'password']: if hasattr(settings, x): delattr(settings, x) elif settings.interactive: # prompt for username if we were not supplied with it if not hasattr(settings, 'user'): log_info('No username given.') settings.user = input('Username: ') # prompt for password if we were not supplied with it if not hasattr(settings, 'password'): if not hasattr(settings, 'passwordcmd'): log_info('No password given.') settings.password = getpass.getpass() else: process = subprocess.Popen(settings.passwordcmd, shell=True, stdout=subprocess.PIPE) password, _ = process.communicate() settings.password = password.splitlines()[0] def list_bugs(buglist, settings): for bug in buglist: bugid = bug['id'] status = bug['status'] priority = bug['priority'] severity = bug['severity'] assignee = bug['assigned_to'].split('@')[0] desc = bug['summary'] line = '%s' % (bugid) if hasattr(settings, 'show_status'): line = '%s %-12s' % (line, status) if hasattr(settings, 'show_priority'): line = '%s %-12s' % (line, priority) if hasattr(settings, 'show_severity'): line = '%s %-12s' % (line, severity) line = '%s %-20s' % (line, assignee) line = '%s %s' % (line, desc) print(line[:settings.columns]) log_info("%i bug(s) found." % len(buglist)) def prompt_for_bug(settings): """ Prompt for the information for a bug """ log_info('Press Ctrl+C at any time to abort.') if not hasattr(settings, 'product'): product = None while not product or len(product) < 1: product = input('Enter product: ') settings.product = product else: log_info('Enter product: %s' % settings.product) if not hasattr(settings, 'component'): component = None while not component or len(component) < 1: component = input('Enter component: ') settings.component = component else: log_info('Enter component: %s' % settings.component) if not hasattr(settings, 'version'): line = input('Enter version (default: unspecified): ') if len(line): settings.version = line else: settings.version = 'unspecified' else: log_info('Enter version: %s' % settings.version) if not hasattr(settings, 'summary'): summary = None while not summary or len(summary) < 1: summary = input('Enter title: ') settings.summary = summary else: log_info('Enter title: %s' % settings.summary) if not hasattr(settings, 'description'): line = block_edit('Enter bug description: ') if len(line): settings.description = line else: log_info('Enter bug description: %s' % settings.description) if not hasattr(settings, 'op_sys'): op_sys_msg = 'Enter operating system where this bug occurs: ' line = input(op_sys_msg) if len(line): settings.op_sys = line else: log_info('Enter operating system: %s' % settings.op_sys) if not hasattr(settings, 'platform'): platform_msg = 'Enter hardware platform where this bug occurs: ' line = input(platform_msg) if len(line): settings.platform = line else: log_info('Enter hardware platform: %s' % settings.platform) if not hasattr(settings, 'priority'): priority_msg = 'Enter priority (eg. Normal) (optional): ' line = input(priority_msg) if len(line): settings.priority = line else: log_info('Enter priority (optional): %s' % settings.priority) if not hasattr(settings, 'severity'): severity_msg = 'Enter severity (eg. normal) (optional): ' line = input(severity_msg) if len(line): settings.severity = line else: log_info('Enter severity (optional): %s' % settings.severity) if not hasattr(settings, 'alias'): alias_msg = 'Enter an alias for this bug (optional): ' line = input(alias_msg) if len(line): settings.alias = line else: log_info('Enter alias (optional): %s' % settings.alias) if not hasattr(settings, 'assigned_to'): assign_msg = 'Enter assignee (eg. liquidx@gentoo.org) (optional): ' line = input(assign_msg) if len(line): settings.assigned_to = line else: log_info('Enter assignee (optional): %s' % settings.assigned_to) if not hasattr(settings, 'cc'): cc_msg = 'Enter a CC list (comma separated) (optional): ' line = input(cc_msg) if len(line): settings.cc = re.split(r',\s*', line) else: log_info('Enter a CC list (optional): %s' % settings.cc) if not hasattr(settings, 'url'): url_msg = 'Enter a URL (optional): ' line = input(url_msg) if len(line): settings.url = line else: log_info('Enter a URL (optional): %s' % settings.url) # fixme: groups # fixme: status # fixme: milestone if not hasattr(settings, 'append_command'): line = input('Append the output of the' ' following command (leave blank for none): ') if len(line): settings.append_command = line else: log_info('Append command (optional): %s' % settings.append_command) def show_bug_info(bug, settings): FieldMap = { 'alias': 'Alias', 'summary': 'Title', 'status': 'Status', 'resolution': 'Resolution', 'product': 'Product', 'component': 'Component', 'version': 'Version', 'platform': 'Hardware', 'op_sys': 'OpSystem', 'priority': 'Priority', 'severity': 'Severity', 'target_milestone': 'TargetMilestone', 'assigned_to': 'AssignedTo', 'url': 'URL', 'whiteboard': 'Whiteboard', 'keywords': 'Keywords', 'depends_on': 'dependsOn', 'blocks': 'Blocks', 'creation_time': 'Reported', 'creator': 'Reporter', 'last_change_time': 'Updated', 'cc': 'CC', 'see_also': 'See Also', } SkipFields = ['assigned_to_detail', 'cc_detail', 'creator_detail', 'id', 'is_confirmed', 'is_creator_accessible', 'is_cc_accessible', 'is_open', 'update_token'] for field in bug: if field in SkipFields: continue if field in FieldMap: desc = FieldMap[field] else: desc = field value = bug[field] if field in ['cc', 'see_also']: for x in value: print('%-12s: %s' % (desc, x)) elif isinstance(value, list): s = ', '.join(["%s" % x for x in value]) if s: print('%-12s: %s' % (desc, s)) elif value is not None and value != '': print('%-12s: %s' % (desc, value)) if not hasattr(settings, 'no_attachments'): params = {'ids': [bug['id']]} bug_attachments = settings.call_bz(settings.bz.Bug.attachments, params) bug_attachments = bug_attachments['bugs']['%s' % bug['id']] print('%-12s: %d' % ('Attachments', len(bug_attachments))) print() for attachment in bug_attachments: aid = attachment['id'] desc = attachment['summary'] when = attachment['creation_time'] print('[Attachment] [%s] [%s]' % (aid, desc)) if not hasattr(settings, 'no_comments'): params = {'ids': [bug['id']]} bug_comments = settings.call_bz(settings.bz.Bug.comments, params) bug_comments = bug_comments['bugs']['%s' % bug['id']]['comments'] print('%-12s: %d' % ('Comments', len(bug_comments))) print() i = 0 wrapper = textwrap.TextWrapper(width=settings.columns, break_long_words=False, break_on_hyphens=False) for comment in bug_comments: who = comment['creator'] when = comment['time'] what = comment['text'] print('[Comment #%d] %s : %s' % (i, who, when)) print('-' * (settings.columns - 1)) if what is None: what = '' # print wrapped version for line in what.splitlines(): if len(line) < settings.columns: print(line) else: for shortline in wrapper.wrap(line): print(shortline) print() i += 1 def attach(settings): """ Attach a file to a bug given a filename. """ filename = getattr(settings, 'filename', None) content_type = getattr(settings, 'content_type', None) bugid = getattr(settings, 'bugid', None) summary = getattr(settings, 'summary', None) is_patch = getattr(settings, 'is_patch', None) comment = getattr(settings, 'comment', None) if not os.path.exists(filename): raise BugzError('File not found: %s' % filename) if content_type is None: content_type = get_content_type(filename) if comment is None: comment = block_edit('Enter optional long description of attachment') if summary is None: summary = os.path.basename(filename) params = {} params['ids'] = [bugid] fd = open(filename, 'rb') params['data'] = xmlrpc.client.Binary(fd.read()) fd.close() params['file_name'] = os.path.basename(filename) params['summary'] = summary params['content_type'] = content_type params['comment'] = comment if is_patch is not None: params['is_patch'] = is_patch check_auth(settings) result = settings.call_bz(settings.bz.Bug.add_attachment, params) attachid = result['ids'][0] log_info('{0} ({1}) has been attached to bug {2}'.format( filename, attachid, bugid)) def attachment(settings): """ Download or view an attachment given the id.""" log_info('Getting attachment %s' % settings.attachid) params = {} params['attachment_ids'] = [settings.attachid] check_auth(settings) result = settings.call_bz(settings.bz.Bug.attachments, params) result = result['attachments'][settings.attachid] view = hasattr(settings, 'view') action = {True: 'Viewing', False: 'Saving'} log_info('%s attachment: "%s"' % (action[view], result['file_name'])) safe_filename = os.path.basename(re.sub(r'\.\.', '', result['file_name'])) if view: print(result['data'].data.decode('utf-8')) else: if os.path.exists(result['file_name']): raise RuntimeError('Filename already exists') fd = open(safe_filename, 'wb') fd.write(result['data'].data) fd.close() def get(settings): """ Fetch bug details given the bug id """ check_auth(settings) log_info('Getting bug %s ..' % settings.bugid) params = {'ids': [settings.bugid]} result = settings.call_bz(settings.bz.Bug.get, params) for bug in result['bugs']: show_bug_info(bug, settings) def modify(settings): """Modify an existing bug (eg. adding a comment or changing resolution.)""" if hasattr(settings, 'comment_from'): try: if settings.comment_from == '-': settings.comment = sys.stdin.read() else: settings.comment = open(settings.comment_from, 'r').read() except IOError as error: raise BugzError('unable to read file: %s: %s' % (settings.comment_from, error)) if hasattr(settings, 'assigned_to') and \ hasattr(settings, 'reset_assigned_to'): raise BugzError('--assigned-to and --unassign cannot be used together') if hasattr(settings, 'comment_editor'): settings.comment = block_edit('Enter comment:') params = {} params['ids'] = [settings.bugid] if hasattr(settings, 'alias'): params['alias'] = settings.alias if hasattr(settings, 'assigned_to'): params['assigned_to'] = settings.assigned_to if hasattr(settings, 'blocks_add'): if 'blocks' not in params: params['blocks'] = {} params['blocks']['add'] = settings.blocks_add if hasattr(settings, 'blocks_remove'): if 'blocks' not in params: params['blocks'] = {} params['blocks']['remove'] = settings.blocks_remove if hasattr(settings, 'depends_on_add'): if 'depends_on' not in params: params['depends_on'] = {} params['depends_on']['add'] = settings.depends_on_add if hasattr(settings, 'depends_on_remove'): if 'depends_on' not in params: params['depends_on'] = {} params['depends_on']['remove'] = settings.depends_on_remove if hasattr(settings, 'cc_add'): if 'cc' not in params: params['cc'] = {} params['cc']['add'] = settings.cc_add if hasattr(settings, 'cc_remove'): if 'cc' not in params: params['cc'] = {} params['cc']['remove'] = settings.cc_remove if hasattr(settings, 'comment'): if 'comment' not in params: params['comment'] = {} params['comment']['body'] = settings.comment if hasattr(settings, 'component'): params['component'] = settings.component if hasattr(settings, 'dupe_of'): params['dupe_of'] = settings.dupe_of if hasattr(settings, 'deadline'): params['deadline'] = settings.deadline if hasattr(settings, 'estimated_time'): params['estimated_time'] = settings.estimated_time if hasattr(settings, 'remaining_time'): params['remaining_time'] = settings.remaining_time if hasattr(settings, 'work_time'): params['work_time'] = settings.work_time if hasattr(settings, 'groups_add'): if 'groups' not in params: params['groups'] = {} params['groups']['add'] = settings.groups_add if hasattr(settings, 'groups_remove'): if 'groups' not in params: params['groups'] = {} params['groups']['remove'] = settings.groups_remove if hasattr(settings, 'keywords_set'): if 'keywords' not in params: params['keywords'] = {} params['keywords']['set'] = settings.keywords_set if hasattr(settings, 'op_sys'): params['op_sys'] = settings.op_sys if hasattr(settings, 'platform'): params['platform'] = settings.platform if hasattr(settings, 'priority'): params['priority'] = settings.priority if hasattr(settings, 'product'): params['product'] = settings.product if hasattr(settings, 'resolution'): if not hasattr(settings, 'dupe_of'): params['resolution'] = settings.resolution if hasattr(settings, 'see_also_add'): if 'see_also' not in params: params['see_also'] = {} params['see_also']['add'] = settings.see_also_add if hasattr(settings, 'see_also_remove'): if 'see_also' not in params: params['see_also'] = {} params['see_also']['remove'] = settings.see_also_remove if hasattr(settings, 'severity'): params['severity'] = settings.severity if hasattr(settings, 'status'): if not hasattr(settings, 'dupe_of'): params['status'] = settings.status if hasattr(settings, 'summary'): params['summary'] = settings.summary if hasattr(settings, 'url'): params['url'] = settings.url if hasattr(settings, 'version'): params['version'] = settings.version if hasattr(settings, 'whiteboard'): params['whiteboard'] = settings.whiteboard if hasattr(settings, 'fixed'): params['status'] = 'RESOLVED' params['resolution'] = 'FIXED' if hasattr(settings, 'invalid'): params['status'] = 'RESOLVED' params['resolution'] = 'INVALID' if len(params) < 2: raise BugzError('No changes were specified') check_auth(settings) result = settings.call_bz(settings.bz.Bug.update, params) for bug in result['bugs']: changes = bug['changes'] if not len(changes): log_info('Added comment to bug %s' % bug['id']) else: log_info('Modified the following fields in bug %s' % bug['id']) for key in changes: log_info('%-12s: removed %s' % (key, changes[key]['removed'])) log_info('%-12s: added %s' % (key, changes[key]['added'])) def post(settings): """Post a new bug""" check_auth(settings) # load description from file if possible if hasattr(settings, 'description_from'): try: if settings.description_from == '-': settings.description = sys.stdin.read() else: settings.description = \ open(settings.description_from, 'r').read() except IOError as error: raise BugzError('Unable to read from file: %s: %s' % (settings.description_from, error)) if not hasattr(settings, 'batch'): prompt_for_bug(settings) # raise an exception if mandatory fields are not specified. if not hasattr(settings, 'product'): raise RuntimeError('Product not specified') if not hasattr(settings, 'component'): raise RuntimeError('Component not specified') if not hasattr(settings, 'summary'): raise RuntimeError('Title not specified') if not hasattr(settings, 'description'): raise RuntimeError('Description not specified') # append the output from append_command to the description append_command = getattr(settings, 'append_command', None) if append_command is not None and append_command != '': append_command_output = subprocess.getoutput(append_command) settings.description = settings.description + '\n\n' + \ '$ ' + append_command + '\n' + \ append_command_output # print submission confirmation print('-' * (settings.columns - 1)) print('%-12s: %s' % ('Product', settings.product)) print('%-12s: %s' % ('Component', settings.component)) print('%-12s: %s' % ('Title', settings.summary)) if hasattr(settings, 'version'): print('%-12s: %s' % ('Version', settings.version)) print('%-12s: %s' % ('Description', settings.description)) if hasattr(settings, 'op_sys'): print('%-12s: %s' % ('Operating System', settings.op_sys)) if hasattr(settings, 'platform'): print('%-12s: %s' % ('Platform', settings.platform)) if hasattr(settings, 'priority'): print('%-12s: %s' % ('Priority', settings.priority)) if hasattr(settings, 'severity'): print('%-12s: %s' % ('Severity', settings.severity)) if hasattr(settings, 'alias'): print('%-12s: %s' % ('Alias', settings.alias)) if hasattr(settings, 'assigned_to'): print('%-12s: %s' % ('Assigned to', settings.assigned_to)) if hasattr(settings, 'cc'): print('%-12s: %s' % ('CC', settings.cc)) if hasattr(settings, 'url'): print('%-12s: %s' % ('URL', settings.url)) # fixme: groups # fixme: status # fixme: Milestone print('-' * (settings.columns - 1)) if not hasattr(settings, 'batch'): if settings.default_confirm in ['Y', 'y']: confirm = input('Confirm bug submission (Y/n)? ') else: confirm = input('Confirm bug submission (y/N)? ') if len(confirm) < 1: confirm = settings.default_confirm if confirm[0] not in ('y', 'Y'): log_info('Submission aborted') return params = {} params['product'] = settings.product params['component'] = settings.component if hasattr(settings, 'version'): params['version'] = settings.version params['summary'] = settings.summary if hasattr(settings, 'description'): params['description'] = settings.description if hasattr(settings, 'op_sys'): params['op_sys'] = settings.op_sys if hasattr(settings, 'platform'): params['platform'] = settings.platform if hasattr(settings, 'priority'): params['priority'] = settings.priority if hasattr(settings, 'severity'): params['severity'] = settings.severity if hasattr(settings, 'alias'): params['alias'] = settings.alias if hasattr(settings, 'assigned_to'): params['assigned_to'] = settings.assigned_to if hasattr(settings, 'cc'): params['cc'] = settings.cc if hasattr(settings, 'url'): params['url'] = settings.url result = settings.call_bz(settings.bz.Bug.create, params) log_info('Bug %d submitted' % result['id']) def search(settings): """Performs a search on the bugzilla database with the keywords given on the title (or the body if specified). """ valid_keys = ['alias', 'assigned_to', 'component', 'creator', 'limit', 'offset', 'op_sys', 'platform', 'priority', 'product', 'resolution', 'severity', 'version', 'whiteboard', 'cc'] params = {} d = vars(settings) for key in d: if key in valid_keys: params[key] = d[key] if 'search_statuses' in d: if 'all' not in d['search_statuses']: params['status'] = d['search_statuses'] if 'terms' in d: params['summary'] = d['terms'] if not params: raise BugzError('Please give search terms or options.') log_info('Searching for bugs meeting the following criteria:') for key in params: log_info(' {0:<20} = {1}'.format(key, params[key])) check_auth(settings) result = settings.call_bz(settings.bz.Bug.search, params)['bugs'] if not len(result): log_info('No bugs found.') else: list_bugs(result, settings) def connections(settings): print('Known bug trackers:') print() for tracker in settings.connections: print(tracker) def main(): ArgParser = make_arg_parser() args = ArgParser.parse_args() ConfigParser = load_config(getattr(args, 'config_file', None)) check_bugz_token() settings = Settings(args, ConfigParser) if not hasattr(args, 'func'): ArgParser.print_usage() return 1 try: args.func(settings) except BugzError as error: log_error(error) return 1 except RuntimeError as error: log_error(error) return 1 except KeyboardInterrupt: log_info('Stopped due to keyboard interrupt') return 1 return 0 if __name__ == "__main__": if sys.version_info >= (3, 7): sys.stdout.reconfigure(encoding='utf-8') main() pybugz-0.14/bugz/cli_argparser.py000066400000000000000000000425141457040153700171300ustar00rootroot00000000000000import argparse import bugz.cli from bugz import __version__ def make_arg_parser(): parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS) parser.add_argument('--config-file', help='read an alternate configuration file') parser.add_argument('--connection', help='use [connection] section of your ' 'configuration file') parser.add_argument('-b', '--base', help='base URL of Bugzilla') parser.add_argument('-u', '--user', help='username') parser.add_argument('-p', '--password', help='password') parser.add_argument('--passwordcmd', help='command to evaluate for the password') parser.add_argument('-k', '--key', help='API key') parser.add_argument('-q', '--quiet', action='store_true', help='quiet mode') parser.add_argument('-d', '--debug', type=int, help='debug level (from 0 to 3)') parser.add_argument('--columns', type=int, help='maximum number of columns output should use') parser.add_argument('--encoding', help='output encoding (default: utf-8) (deprecated)') parser.add_argument('--skip-auth', action='store_true', help='skip Authentication.') parser.add_argument('--insecure', action='store_true', help='do not verify ssl certificate') parser.add_argument('--interactive', action='store_true', help='prompt for username and password if ' 'they are not specified') parser.add_argument('--version', action='version', help='show program version and exit', version='%(prog)s ' + __version__) subparsers = parser.add_subparsers(title='sub-commands', description='use -h after ' 'a sub-command for more help') attach_parser = subparsers.add_parser('attach', argument_default=argparse.SUPPRESS, help='attach file to a bug') attach_parser.add_argument('bugid', help='the ID of the bug where the file ' 'should be attached') attach_parser.add_argument('filename', help='the name of the file to attach') attach_parser.add_argument('-c', '--content-type', help='mimetype of the file e.g. ' 'text/plain (default: auto-detect)') attach_parser.add_argument('-d', '--description', dest='comment', help='a long description of the attachment') attach_parser.add_argument('-p', '--patch', action='store_true', dest='is_patch', help='attachment is a patch') attach_parser.add_argument('-t', '--title', dest='summary', help='a short description of the ' 'attachment (default: filename).') attach_parser.set_defaults(func=bugz.cli.attach) attachment_parser = subparsers.add_parser('attachment', argument_default=argparse.SUPPRESS, help='get an attachment ' 'from Bugzilla') attachment_parser.add_argument('attachid', help='the ID of the attachment') attachment_parser.add_argument('-v', '--view', action="store_true", help='print attachment rather than save') attachment_parser.set_defaults(func=bugz.cli.attachment) connections_parser = subparsers.add_parser('connections', help='list known bug trackers') connections_parser.set_defaults(func=bugz.cli.connections) get_parser = subparsers.add_parser('get', argument_default=argparse.SUPPRESS, help='get a bug from bugzilla') get_parser.add_argument('bugid', help='the ID of the bug to retrieve') get_parser.add_argument("-a", "--no-attachments", action="store_true", help='do not show attachments') get_parser.add_argument("-n", "--no-comments", action="store_true", help='do not show comments') get_parser.set_defaults(func=bugz.cli.get) modify_parser = subparsers.add_parser('modify', argument_default=argparse.SUPPRESS, help='modify a bug ' '(eg. post a comment)') modify_parser.add_argument('bugid', help='the ID of the bug to modify') modify_parser.add_argument('--alias', help='change the alias for this bug') modify_parser.add_argument('-a', '--assigned-to', help='change assignee for this bug') modify_parser.add_argument('--add-blocked', action='append', dest='blocks_add', help='add a bug to the blocked list') modify_parser.add_argument('--remove-blocked', action='append', dest='blocks_remove', help='remove a bug from the blocked list') modify_parser.add_argument('--add-dependson', action='append', dest='depends_on_add', help='add a bug to the depends list') modify_parser.add_argument('--remove-dependson', action='append', dest='depends_on_remove', help='remove a bug from the depends list') modify_parser.add_argument('--add-cc', action='append', dest='cc_add', help='add an email to the CC list') modify_parser.add_argument('--remove-cc', action='append', dest='cc_remove', help='remove an email from the CC list') modify_parser.add_argument('-c', '--comment', help='add comment from command line') modify_parser.add_argument('-C', '--comment-editor', action='store_true', help='add comment via default editor') modify_parser.add_argument('-F', '--comment-from', help='add comment from file. If -C is ' 'also specified, the editor will be opened ' 'with this file as its contents.') modify_parser.add_argument('--component', help='change the component for this bug') modify_parser.add_argument('--deadline', help='deadline for bug (format YYYY-MM-DD)') modify_parser.add_argument('-d', '--duplicate', dest='dupe_of', type=int, help='this bug is a duplicate') modify_parser.add_argument('--estimated-time', dest='estimated_time', type=float, help='The total estimate of time required to ' 'fix the bug, in hours') modify_parser.add_argument('--remaining-time', dest='remaining_time', type=float, help='How much work time is remaining to fix ' 'the bug, in hours') modify_parser.add_argument('--work-time', dest='work_time', type=float, help='The number of hours spent on this bug') modify_parser.add_argument('--add-group', action='append', dest='groups_add', help='add a group to this bug') modify_parser.add_argument('--remove-group', action='append', dest='groups_remove', help='remove agroup from this bug') modify_parser.add_argument('--set-keywords', action='append', dest='keywords_set', help='set bug keywords') modify_parser.add_argument('--op-sys', help='change the operating system for this bug') modify_parser.add_argument('--platform', help='change the hardware platform ' 'for this bug') modify_parser.add_argument('--priority', help='change the priority for this bug') modify_parser.add_argument('--product', help='change the product for this bug') modify_parser.add_argument('-r', '--resolution', help='set new resolution ' '(if status = RESOLVED)') modify_parser.add_argument('--add-see-also', action='append', dest='see_also_add', help='add a "see also" URL to this bug') modify_parser.add_argument('--remove-see-also', action='append', dest='see_also_remove', help='remove a"see also" URL from this bug') modify_parser.add_argument('-S', '--severity', help='set severity for this bug') modify_parser.add_argument('-s', '--status', help='set new status of bug (eg. RESOLVED)') modify_parser.add_argument('-t', '--title', dest='summary', help='set title of bug') modify_parser.add_argument('-u', '--unassign', action='store_true', dest='reset_assigned_to', help='Reassign the bug to the default owner') modify_parser.add_argument('-U', '--url', help='set URL field of bug') modify_parser.add_argument('-v', '--version', help='set the version for this bug') modify_parser.add_argument('-w', '--whiteboard', help='set Status whiteboard') modify_parser.add_argument('--fixed', action='store_true', help='mark bug as RESOLVED, FIXED') modify_parser.add_argument('--invalid', action='store_true', help='mark bug as RESOLVED, INVALID') modify_parser.set_defaults(func=bugz.cli.modify) post_parser = subparsers.add_parser('post', argument_default=argparse.SUPPRESS, help='post a new bug into bugzilla') post_parser.add_argument('--product', help='product') post_parser.add_argument('--component', help='component') post_parser.add_argument('--version', help='version of the product') post_parser.add_argument('-t', '--title', dest='summary', help='title of bug') post_parser.add_argument('-d', '--description', help='description of the bug') post_parser.add_argument('--op-sys', help='set the operating system') post_parser.add_argument('--platform', help='set the hardware platform') post_parser.add_argument('--priority', help='set priority for the new bug') post_parser.add_argument('-S', '--severity', help='set the severity for the new bug') post_parser.add_argument('--alias', help='set the alias for this bug') post_parser.add_argument('-a', '--assigned-to', help='assign the bug to someone') post_parser.add_argument('--cc', help='add a list of emails to CC list') post_parser.add_argument('-U', '--url', help='set URL field of bug') post_parser.add_argument('-F', '--description-from', help='load description from file') post_parser.add_argument('--append-command', help='append output from command to description') post_parser.add_argument('--batch', action="store_true", help='do not prompt for any values') post_parser.add_argument('--default-confirm', choices=['y', 'Y', 'n', 'N'], default='y', help='default answer to confirmation question') post_parser.set_defaults(func=bugz.cli.post) search_parser = subparsers.add_parser('search', argument_default=argparse.SUPPRESS, help='search for bugs in bugzilla') search_parser.add_argument('terms', nargs='*', help='strings to search for in ' 'the title and/or body') search_parser.add_argument('--alias', help='The unique alias for this bug') search_parser.add_argument('-a', '--assigned-to', help='email the bug is assigned to') search_parser.add_argument('--cc', help='email in the CC list for the bug') search_parser.add_argument('-C', '--component', action='append', help='restrict by component (1 or more)') search_parser.add_argument('-r', '--creator', help='email of the person who created the bug') search_parser.add_argument('-l', '--limit', type=int, help='Limit the number of records ' 'returned by a search') search_parser.add_argument('--offset', type=int, help='Set the start position for a search') search_parser.add_argument('--op-sys', action='append', help='restrict by Operating System ' '(one or more)') search_parser.add_argument('--platform', action='append', help='restrict by platform (one or more)') search_parser.add_argument('--priority', action='append', help='restrict by priority (one or more)') search_parser.add_argument('--product', action='append', help='restrict by product (one or more)') search_parser.add_argument('--resolution', help='restrict by resolution') search_parser.add_argument('--severity', action='append', help='restrict by severity (one or more)') search_parser.add_argument('-s', '--status', action='append', dest='search_statuses', help='restrict by status ' '(one or more, use all for all statuses)') search_parser.add_argument('-v', '--version', action='append', help='restrict by version (one or more)') search_parser.add_argument('-w', '--whiteboard', help='status whiteboard') search_parser.add_argument('--show-status', action='store_true', help='show status of bugs') search_parser.add_argument('--show-priority', action='store_true', help='show priority of bugs') search_parser.add_argument('--show-severity', action='store_true', help='show severity of bugs') search_parser.set_defaults(func=bugz.cli.search) return parser pybugz-0.14/bugz/configfile.py000066400000000000000000000027111457040153700164130ustar00rootroot00000000000000import configparser import glob import os import sys from bugz.log import log_error def load_config(UserConfig=None): parser = configparser.ConfigParser(default_section='default') DefaultConfigs = sorted(glob.glob(sys.prefix + '/share/pybugz.d/*.conf')) SystemConfigs = sorted(glob.glob('/etc/pybugz.d/*.conf')) if UserConfig is not None: UserConfig = os.path.expanduser(UserConfig) else: UserConfig = os.path.expanduser('~/.bugzrc') try: parser.read(DefaultConfigs + SystemConfigs + [UserConfig]) except configparser.DuplicateOptionError as error: log_error(error) sys.exit(1) except configparser.DuplicateSectionError as error: log_error(error) sys.exit(1) except configparser.MissingSectionHeaderError as error: log_error(error) sys.exit(1) except configparser.ParsingError as error: log_error(error) sys.exit(1) return parser def get_config_option(get, section, option): try: value = get(section, option) except configparser.InterpolationSyntaxError as error: log_error('Syntax Error in configuration file: {0}'.format(error)) sys.exit(1) except ValueError as error: log_error('{0} is not in the right format: {1}'.format(option, str(error))) sys.exit(1) if value == '': log_error('{0} is not set'.format(option)) sys.exit(1) return value pybugz-0.14/bugz/exceptions.py000066400000000000000000000001061457040153700164630ustar00rootroot00000000000000# # Bugz specific exceptions # class BugzError(Exception): pass pybugz-0.14/bugz/log.py000066400000000000000000000025401457040153700150670ustar00rootroot00000000000000""" This module contains a set of routines for logging messages. If someone wants to convert this to use python's built-in logging, patches are welcome. """ debugLevel = 0 quiet = False LogSettings = { 'W': { 'sym': '!', 'word': 'Warn', }, 'E': { 'sym': '#', 'word': 'Error', }, 'D': { 'sym': '~', 'word': 'Dbg', }, 'I': { 'sym': '*', 'word': 'Info', }, '!': { 'sym': '!', 'word': 'UNKNWN', }, } def log_setQuiet(newQuiet): global quiet quiet = newQuiet def log_setDebugLevel(newLevel): global debugLevel if not newLevel: return if newLevel > 3: log_warn("bad debug level '{0}', using '3'".format(str(newLevel))) debugLevel = 3 else: debugLevel = newLevel def formatOut(msg, id='!'): lines = str(msg).split('\n') sym = LogSettings[id]['sym'] word = LogSettings[id]['word'] + ":" for line in lines: print(' {0} {1} {2}'.format(sym, word, line)) def log_error(string): formatOut(string, 'E') def log_warn(string): formatOut(string, 'W') def log_info(string): # debug implies info if not quiet or debugLevel: formatOut(string, 'I') def log_debug(string, msgLevel=1): if debugLevel >= msgLevel: formatOut(string, 'D') pybugz-0.14/bugz/settings.py000066400000000000000000000155341457040153700161550ustar00rootroot00000000000000import ssl import sys import urllib.error import urllib.parse import xml.parsers.expat import xmlrpc.client from bugz.configfile import get_config_option from bugz.exceptions import BugzError from bugz.log import log_debug, log_error, log_info from bugz.log import log_setDebugLevel, log_setQuiet from bugz.utils import terminal_width class Settings: def __init__(self, args, config): for key in vars(args): setattr(self, key, getattr(args, key)) if not hasattr(self, 'connection'): if config.has_option('default', 'connection'): self.connection = get_config_option(config.get, 'default', 'connection') else: log_error('No default connection specified') sys.exit(1) if self.connection not in config.sections(): log_error('connection "{0}" not found'.format(self.connection)) sys.exit(1) if not hasattr(self, 'base'): if config.has_option(self.connection, 'base'): self.base = get_config_option(config.get, self.connection, 'base') else: log_error('No base URL specified') sys.exit(1) if not hasattr(self, 'component'): if config.has_option(self.connection, 'component'): self.component = get_config_option(config.get, self.connection, 'component') if not hasattr(self, 'user'): if config.has_option(self.connection, 'user'): self.user = get_config_option(config.get, self.connection, 'user') if not hasattr(self, 'password'): if config.has_option(self.connection, 'password'): self.password = get_config_option(config.get, self.connection, 'password') if not hasattr(self, 'passwordcmd'): if config.has_option(self.connection, 'passwordcmd'): self.passwordcmd = get_config_option(config.get, self.connection, 'passwordcmd') if not hasattr(self, 'key'): if config.has_option(self.connection, 'key'): self.key = get_config_option(config.get, self.connection, 'key') if not hasattr(self, 'product'): if config.has_option(self.connection, 'product'): self.product = get_config_option(config.get, self.connection, 'product') if not hasattr(self, 'columns'): if config.has_option(self.connection, 'columns'): self.columns = get_config_option(config.getint, self.connection, 'columns') else: self.columns = terminal_width() if not hasattr(self, 'debug'): if config.has_option(self.connection, 'debug'): self.debug = get_config_option(config.getint, self.connection, 'debug') else: self.debug = 0 log_setDebugLevel(self.debug) if not hasattr(self, 'quiet'): if config.has_option(self.connection, 'quiet'): self.quiet = get_config_option(config.getboolean, self.connection, 'quiet') else: self.quiet = False log_setQuiet(self.quiet) if not hasattr(self, 'search_statuses'): if config.has_option(self.connection, 'search_statuses'): s = get_config_option(config.get, self.connection, 'search_statuses') self.search_statuses = [x.strip() for x in s.split(',')] if not hasattr(self, 'skip_auth'): if config.has_option(self.connection, 'skip_auth'): self.skip_auth = get_config_option(config.getboolean, self.connection, 'skip_auth') else: self.skip_auth = False if not hasattr(self, 'interactive'): if config.has_option(self.connection, 'interactive'): self.interactive = get_config_option(config.getboolean, self.connection, 'interactive') else: self.interactive = False if not hasattr(self, 'insecure'): if config.has_option(self.connection, 'insecure'): self.insecure = get_config_option(config.getboolean, self.connection, 'insecure') else: self.insecure = False if getattr(self, 'encoding', None) is not None: log_info('The encoding option is deprecated.') if self.insecure: context=ssl._create_unverified_context() else: context = None self.bz = xmlrpc.client.ServerProxy(self.base, context=context) self.connections = config.sections() parse_result = urllib.parse.urlparse(self.base) new_netloc = parse_result.netloc.split('@')[-1] self.safe_base = parse_result._replace(netloc=new_netloc).geturl() log_info("Using [{0}] ({1})".format(self.connection, self.safe_base)) log_debug('Command line debug dump:', 3) for key in vars(args): log_debug('{0}, {1}'.format(key, getattr(args, key)), 3) log_debug('Settings debug dump:', 3) for key in vars(self): log_debug('{0}, {1}'.format(key, getattr(self, key)), 3) def call_bz(self, method, params): """Attempt to call method with args. """ if hasattr(self, 'key'): params['Bugzilla_api_key'] = self.key else: if hasattr(self, 'user'): params['Bugzilla_login'] = self.user if hasattr(self, 'password'): params['Bugzilla_password'] = self.password try: return method(params) except xmlrpc.client.Fault as fault: raise BugzError('Bugzilla error: {0}'.format(fault.faultString)) except xmlrpc.client.ProtocolError as error: raise BugzError(error) except urllib.error.URLError as error: raise BugzError(error) except xml.parsers.expat.ExpatError as error: raise BugzError(error) pybugz-0.14/bugz/utils.py000066400000000000000000000054571457040153700154600ustar00rootroot00000000000000import mimetypes import os import re import sys import shutil import tempfile BUGZ_COMMENT_TEMPLATE = """ BUGZ: --------------------------------------------------- %s BUGZ: Any line beginning with 'BUGZ:' will be ignored. BUGZ: --------------------------------------------------- """ DEFAULT_NUM_COLS = 80 # # Auxiliary functions # def get_content_type(filename): # Keep in sync with Lib/mimetypes.py encoding_map = { 'bzip2': 'application/x-bzip2', 'compress': 'application/x-compress', 'gzip': 'application/gzip', 'xz': 'application/x-xz', } # Last addition was brotli, rest have been since 3.4 if sys.version_info >= (3, 9): encoding_map['br'] = 'application/x-brotli' mimetype, encoding = mimetypes.guess_type(filename) or ('application/octet-stream', None) # guess_type returns encoding of the file separately from the encoded file. Leading .txt.gz having # the mime of text/plain, this isn't desirable so return the mimetype of the encoding # https://github.com/williamh/pybugz/issues/113 return mimetype if encoding is None else encoding_map[encoding] def raw_input_block(): """ Allows multiple line input until a Ctrl+D is detected. @rtype: string """ target = '' while True: try: line = input() target += line + '\n' except EOFError: return target # # This function was lifted from Bazaar 1.9. # def terminal_width(): """Return estimated terminal width.""" return shutil.get_terminal_size().columns def launch_editor(initial_text, comment_from='', comment_prefix='BUGZ:'): """Launch an editor with some default text. Lifted from Mercurial 0.9. @rtype: string """ (fd, name) = tempfile.mkstemp("bugz") f = os.fdopen(fd, "w") f.write(comment_from) f.write(initial_text) f.close() editor = (os.environ.get("BUGZ_EDITOR") or os.environ.get("EDITOR")) if editor: result = os.system("%s \"%s\"" % (editor, name)) if result != 0: raise RuntimeError('Unable to launch editor: %s' % editor) new_text = open(name).read() new_text = re.sub('(?m)^%s.*\n' % comment_prefix, '', new_text) os.unlink(name) return new_text return '' def block_edit(comment, comment_from=''): editor = (os.environ.get('BUGZ_EDITOR') or os.environ.get('EDITOR')) if not editor: print(comment + ': (Press Ctrl+D to end)') new_text = raw_input_block() return new_text initial_text = '\n'.join(['BUGZ: %s' % line for line in comment.splitlines()]) new_text = launch_editor(BUGZ_COMMENT_TEMPLATE % initial_text, comment_from) if new_text.strip(): return new_text else: return '' pybugz-0.14/data/000077500000000000000000000000001457040153700136755ustar00rootroot00000000000000pybugz-0.14/data/share/000077500000000000000000000000001457040153700147775ustar00rootroot00000000000000pybugz-0.14/data/share/bash-completion/000077500000000000000000000000001457040153700200635ustar00rootroot00000000000000pybugz-0.14/data/share/bash-completion/completions/000077500000000000000000000000001457040153700224175ustar00rootroot00000000000000pybugz-0.14/data/share/bash-completion/completions/bugz000066400000000000000000000034571457040153700233220ustar00rootroot00000000000000# # Bash completion support for bugz. # # Copyright 2012 Tim Stoakes # # Complete a list of command names by scanning the help output. __bugz_comp_commands_from_help () { local cur="${3#$2}" local opts opts="$($1 --help | \ awk -F, '/^\s+\{/ {for(i=1; i<=NF; ++i) {sub(/\W+/, "", $i); print $i} exit;}')" COMPREPLY=( $( compgen -W "$opts" -- $cur ) ) } # Complete a list of options, both generic, and specific to the given command, # by scanning the help output. __bugz_comp_opts_from_help () { local cur="${3#$2}" local opts if [ "x" == "x$2" ]; then opts="$($1 --help | \ awk '/^\s+-/ {for(i=1; i<=NF; ++i) if ($i~/^-.+$/) {sub(/,$/, "", $i); print $i}}')" COMPREPLY=( $( compgen -W "$opts" -- $cur ) ) else opts="$($1 $2 --help 2>/dev/null | \ awk '/^\s+-/ {for(i=1; i<=NF; ++i) if ($i~/^-.+$/) {sub(/,$/, "", $i); print $i}}')" if [ $? -eq 0 ]; then COMPREPLY=( $( compgen -W "$opts" -- $cur ) ) fi fi } _bugz() { local i c=1 command cur command_valid=0 bugz COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" bugz="${COMP_WORDS[0]}" # Find the command name. while [ $c -le $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in -*) ;; *) # This is the best guess so far. command="$i" # Is it a valid command already? $bugz $i --help > /dev/null 2>&1 if [ $? -eq 0 ]; then # Yes! Stop looking. command_valid=1 break 2 fi ;; esac c=$((++c)) done case "$cur" in -*) # Complete an option. __bugz_comp_opts_from_help "$bugz" "$command" "$cur" return 0 ;; *) if [ $command_valid -ne 1 ]; then # Complete the command name if required. __bugz_comp_commands_from_help "$bugz" "" $command fi # If there's anything left, don't complete it. return 0 ;; esac } complete -F _bugz bugz pybugz-0.14/data/share/man/000077500000000000000000000000001457040153700155525ustar00rootroot00000000000000pybugz-0.14/data/share/man/man1/000077500000000000000000000000001457040153700164065ustar00rootroot00000000000000pybugz-0.14/data/share/man/man1/bugz.1000066400000000000000000000022231457040153700174360ustar00rootroot00000000000000.\" Hey, Emacs! This is an -*- nroff -*- source file. .\" Copyright (c) 2011, 2012, 2013 William Hubbs .\" This is free software; see the GNU General Public Licence version 2 .\" or later for copying conditions. There is NO warranty. .TH bugz 1 "20 Jan 2013" "0.10.2" .nh .SH NAME bugz \(em command line interface to bugzilla .SH SYNOPSIS .B bugz [ .B global options ] .B subcommand [ .B subcommand options ] .\" .SH OPTIONS .\" .TP .\" .B \-o value, \-\^\-long=value .\" Describe the option. .SH DESCRIPTION Bugz is a program which gives you access to the features of the bugzilla bug tracking system from the command line. .PP This man page is a stub; the bugz program has extensive built in help. .B bugz -h will show the help for the global options and .B bugz [subcommand] -h will show the help for a specific subcommand. .SH BUGS .PP The home page of this project is http://www.github.com/williamh/pybugz. Bugs should be reported to the bug tracker there. .SH SEE ALSO .PP \fBpybugz.d\fR(5) .SH AUTHOR .PP The original author is Alastair Tse . The current maintainer is William Hubbs . William also wrote this man page. pybugz-0.14/data/share/man/man5/000077500000000000000000000000001457040153700164125ustar00rootroot00000000000000pybugz-0.14/data/share/man/man5/pybugz.d.5000066400000000000000000000132331457040153700202440ustar00rootroot00000000000000.\" Hey, Emacs! This is an -*- nroff -*- source file. .\" Copyright (c) 2014 William Hubbs .\" This is free software; see the GNU General Public Licence version 2 .\" or later for copying conditions. There is NO warranty. .TH pybugz.d 5 "20 Jan 2013" "0.12" .nh .SH NAME pybugz.d - configuration files for pybugz .SH SYNOPSIS .B /usr/share/pybugz.d/*.conf .PP .B /etc/pybugz.d/*.conf .PP .B ~/.bugzrc .\" .SH OPTIONS .\" .TP .\" .B \-o value, \-\^\-long=value .\" Describe the option. .SH DESCRIPTION When started, bugz reads configuration files from all of the locations listed above, in the order listed. In the directories, it reads the files in lexical order. .PP Files located in /usr/share/pybugz.d/*.conf are provided by pybugz and should not be modified. .PP Files located in /etc/pybugz.d/*.conf, if it exists, are provided by the system administrator. .PP The final file that is read, if it exists, is ~/.bugzrc by default. This is the user-specific configuration file. This file name can be overridden on the command line by using the --config-file option. .SH CONFIGURATION FILE FORMAT A configuration file consists of sections which define parameters for the Bugzillas you intend to use. Each section starts with a case-sensitive section name in square brackets and is followed by the settings, in the form "key = value" or "key : value", which define the parameters for this bugzilla instance. .PP The section name is also the name that should be used with the --connection option of the bugz command or the "connection" setting in the default section of the configuration file. .PP The section named [default] is special. Any settings defined in this section will have the value they are given here in all other sections unless they are overridden. So, for example, if you want to use the same username for most of your bugzillas, define user in the default section. .PP Comments are also allowed. A comment must begin with "#" or ";" and be on a line of its own. .SH CONFIGURATION SETTINGS This is a list of the current settings supported by pybugz. .PP connection = sectionname .PP This is used in the default section to define the bugzilla you connect with most of the time. It is not an error to put it in another section, but it does not make much sense to do so. .PP base = http://my.project.com/bugzilla/xmlrpc.cgi .PP base = http://myhttpname:myhttppasswd@my.project.com/bugzilla/xmlrpc.cgi .PP This is the base URL of the bugzilla. It must point to the xmlrpc.cgi script on the bugzilla installation. The second form is used if you need to encode a username and password into the URL for basic http authentication. .PP user = myname@my.project.com .PP password = secret2 .PP These set your username and password for this bugzilla. If you do not provide one or both of these and you do not use the key setting below, you will be prompted for the setting you do not provide. .PP passwordcmd = gpg --decrypt ~/.my-encrypted-password.gpg .PP As another alternative for storing your password, you can provide a password command. This command will be run, and pybugz expects it to output the password to stdout. The example above uses gpg to decrypt an encrypted password stored in a file. The default setting is undefined, so it will not be used unless you define it. .PP key = string .PP This is your API key, which is an alternative way to authenticate for Bugzilla 5.0 and newer. To use this, you must generate an API key in the preferences section of Bugzilla and set it to that value. This overrides the username and password settings. The default is undefined. .PP columns = 80 .PP This is the number of columns your terminal can display. Most of the time, pybugz should be able to determine this value. If it cannot, the default value is 80, so more than likely you will never have to change this setting. .PP debug = 0 .PP This sets the level of debug logging. This is mostly used for development purposes. It causes PyBugz to print out debugging information as it runs. .PP quiet = False .PP If set to true, this requests that pybugz run in quiet mode. This means only output returned from the Bugzilla will be displayed; several more verbose log messages will not be displayed. .PP product = string .PP This is the default setting for the product field in bugs in this Bugzilla instance. It is possible to define this in the default section. However, it does not make sense to do so most of the time. If this is set, you will not be prompted for a product when you run bugz post, and this value will also be the default for bugz search. .PP component = string .PP This is the default setting for the component field in bugs in this Bugzilla instance. It is possible to define this in the default section. However, it does not make sense to do so most of the time. If this is set, you will not be prompted for a component when you run bugz post, and this will also be the default value for bugz search. .PP search_statuses = confirmed, in_progress, unconfirmed .PP This sets the default statuses to be used in a search command. It is a space separated list of Bugzilla statuses. .PP insecure = true | false .PP If this is set to true, pybugz will not validate the ssl certificate used during an https connection to this site. Do not use this setting unless you know exactly what you are doing. .PP interactive = true | false .PP If this is set to true, pybugz will prompt for a username and password for the bugzilla you are attempting to connect to if no credentials are specified in the configuration file. The default setting is false. .SH BUGS .PP The home page of this project is http://www.github.com/williamh/pybugz. Bugs should be reported to the bug tracker there. .SH SEE ALSO .PP \fBbugz\fR(1) .SH AUTHOR .PP William Hubbs pybugz-0.14/data/share/pybugz.d/000077500000000000000000000000001457040153700165415ustar00rootroot00000000000000pybugz-0.14/data/share/pybugz.d/busybox.conf000066400000000000000000000001531457040153700211020ustar00rootroot00000000000000[BusyBox] base = https://bugs.busybox.net/xmlrpc.cgi search_statuses = CONFIRMED, IN_PROGRESS, UNCONFIRMED pybugz-0.14/data/share/pybugz.d/default.conf000066400000000000000000000000361457040153700210330ustar00rootroot00000000000000[default] connection = Gentoo pybugz-0.14/data/share/pybugz.d/freebsd.conf000066400000000000000000000001641457040153700210230ustar00rootroot00000000000000[FreeBSD] base = https://bugs.freebsd.org/bugzilla/xmlrpc.cgi search_statuses = New, Open, In Progress, UNCONFIRMED pybugz-0.14/data/share/pybugz.d/freedesktop.conf000066400000000000000000000001631457040153700217230ustar00rootroot00000000000000[freedesktop] base = https://bugs.freedesktop.org/xmlrpc.cgi search_statuses = CONFIRMED, IN_PROGRESS, UNCONFIRMED pybugz-0.14/data/share/pybugz.d/gentoo.conf000066400000000000000000000001511457040153700207000ustar00rootroot00000000000000[Gentoo] base = https://bugs.gentoo.org/xmlrpc.cgi search_statuses = CONFIRMED, IN_PROGRESS, UNCONFIRMED pybugz-0.14/data/share/pybugz.d/gnome.conf000066400000000000000000000001531457040153700205140ustar00rootroot00000000000000[gnome] base = https://bugzilla.gnome.org/xmlrpc.cgi search_statuses = CONFIRMED, IN_PROGRESS, UNCONFIRMED pybugz-0.14/data/share/pybugz.d/kernel.conf000066400000000000000000000001551457040153700206710ustar00rootroot00000000000000[Kernel] base = https://bugzilla.kernel.org/xmlrpc.cgi search_statuses = CONFIRMED, IN_PROGRESS, UNCONFIRMED pybugz-0.14/data/share/pybugz.d/libav.conf000066400000000000000000000001421457040153700205020ustar00rootroot00000000000000[libav] base = https://bugzilla.libav.org/xmlrpc.cgi search_statuses = new, reopened, unconfirmed pybugz-0.14/data/share/pybugz.d/llvm.conf000066400000000000000000000001451457040153700203620ustar00rootroot00000000000000[LLVM] base = https://llvm.org/bugs/xmlrpc.cgi search_statuses = confirmed, in_progress, unconfirmed pybugz-0.14/data/share/pybugz.d/mozilla.conf000066400000000000000000000001571457040153700210620ustar00rootroot00000000000000[Mozilla] base = https://bugzilla.mozilla.org/xmlrpc.cgi search_statuses = CONFIRMED, IN_PROGRESS, UNCONFIRMED pybugz-0.14/data/share/pybugz.d/redhat.conf000066400000000000000000000001571457040153700206620ustar00rootroot00000000000000[RedHat] base = https://bugzilla.redhat.com/xmlrpc.cgi search_statuses = NEW, ASSIGNED, MODIFIED, ON_DEV, POST pybugz-0.14/data/share/zsh/000077500000000000000000000000001457040153700156035ustar00rootroot00000000000000pybugz-0.14/data/share/zsh/site-functions/000077500000000000000000000000001457040153700205555ustar00rootroot00000000000000pybugz-0.14/data/share/zsh/site-functions/_pybugz000066400000000000000000000140261457040153700221620ustar00rootroot00000000000000#compdef bugz # Copyright 2009 Ingmar Vanhassel # vim: set et sw=2 sts=2 ts=2 ft=zsh : _bugz() { local -a _bugz_options _bugz_commands local cmd _bugz_options=( '(-b --base)'{-b,--base}'[bugzilla base URL]:bugzilla url: ' '(-u --user)'{-u,--user}'[user name (if required)]:user name:_users' '(-p --password)'{-p,--password}'[password (if required)]:password: ' '--columns[number of columns to use when displaying output]:number: ' '--skip-auth[do not authenticate]' '(-q --quiet)'{-q,--quiet}'[do not display status messages]' ) _bugz_commands=( 'attach:attach file to a bug' 'attachment:get an attachment from bugzilla' 'get:get a bug from bugzilla' 'help:display subcommands' 'modify:modify a bug (eg. post a comment)' 'post:post a new bug into bugzilla' 'search:search for bugs in bugzilla' ) for (( i=1; i <= ${CURRENT}; i++ )); do cmd=${_bugz_commands[(r)${words[${i}]}:*]%%:*} (( ${#cmd} )) && break done if (( ${#cmd} )); then local curcontext="${curcontext%:*:*}:bugz-${cmd}:" while [[ ${words[1]} != ${cmd} ]]; do (( CURRENT-- )) shift words done _call_function ret _bugz_cmd_${cmd} return ret else _arguments -s : $_bugz_options _describe -t commands 'commands' _bugz_commands fi } (( ${+functions[_bugz_cmd_attach]} )) || _bugz_cmd_attach() { _arguments -s : \ '(--content_type= -c)'{--content_type=,-c}'[mimetype of the file]:MIME-Type:_mime_types' \ '(--title= -t)'{--title=,-t}'[a short description of the attachment]:title: ' \ '(--description= -d)'{--description=,-d}'[a long description of the attachment]:description: ' \ '(--bigfile)'{--bigfile}'[the attachment is a big file]:bigfile: ' \ '--help[show help message and exit]' } (( ${+functions[_bugz_cmd_attachment]} )) || _bugz_cmd_attachment() { _arguments -s : \ '--help[show help message and exit]' \ '(--view -v)'{--view,-v}'[print attachment rather than save]' } (( ${+functions[_bugz_cmd_get]} )) || _bugz_cmd_get() { _arguments -s : \ '--help[show help message and exit]' \ '(--no-comments -n)'{--no-comments,-n}'[do not show comments]' } (( ${+functions[_bugz_cmd_modify]} )) || _bugz_cmd_modify() { _arguments -s : \ '--add-blocked=[add a bug to the blocked list]:bug: ' \ '--add-dependson=[add a bug to the depends list]:bug: ' \ '--add-cc=[add an email to CC list]:email: ' \ '(--assigned-to= -a)'{--assigned-to=,-a}'[assign bug to someone other than the default assignee]:assignee: ' \ '(--comment= -c)'{--comment=,-c}'[add comment to bug]:Comment: ' \ '(--comment-editor -C)'{--comment-editor,-C}'[add comment via default EDITOR]' \ '(--comment-from= -F)'{--comment-from=,-F}'[add comment from file]:file:_files' \ '(--duplicate= -d)'{--duplicate=,-d}'[mark bug as a duplicate of bug number]:bug: ' \ '--fixed[mark bug as RESOLVED, FIXED]' \ '--help[show help message and exit]' \ '--invalid[mark bug as RESOLVED, INVALID]' \ '(--keywords= -k)'{--keywords=,-k}'[list of bugzilla keywords]:keywords: ' \ '--priority=[set the priority field of the bug]:priority: ' \ '(--resolution= -r)'{--resolution=,-r}'[set new resolution (only if status = RESOLVED)]' \ '--remove-cc=[remove an email from the CC list]:email: ' \ '--remove-dependson=[remove a bug from the depends list]:bug: ' \ '--remove-blocked=[remove a bug from the blocked list]:bug: ' \ '(--severity= -S)'{--severity=,-S}'[set severity of the bug]:severity: ' \ '(--status -s=)'{--status=,-s}'[set new status of bug (eg. RESOLVED)]:status: ' \ '(--title= -t)'{--title=,-t}'[set title of the bug]:title: ' \ '(--url= -U)'{--url=,-u}'[set URL field of the bug]:URL: ' \ '(--whiteboard= -w)'{--whiteboard=,-w}'[set status whiteboard]:status whiteboard: ' } (( ${+functions[_bugz_cmd_post]} )) || _bugz_cmd_post() { _arguments -s : \ '(--assigned-to= -a)'{--assigned-to=,-a}'[assign bug to someone other than the default assignee]:assignee: ' \ '--batch[work in batch mode, non-interactively]' \ '--blocked[add a list of blocker bugs]:blockers: ' \ '--cc=[add a list of emails to cc list]:email(s): ' \ '--commenter[email of a commenter]:email: ' \ '--depends-on[add a list of bug dependencies]:dependencies: ' \ '(--description= -d)'{--description=,-d}'[description of the bug]:description: ' \ '(--description-from= -F)'{--description-from=,-f}'[description from contents of a file]:file:_files' \ '--help[show help message and exit]' \ '(--keywords= -k)'{--keywords=,-k}'[list of bugzilla keywords]:keywords: ' \ '(--append-command)--no-append-command[do not append command output]' \ '(--title= -t)'{--title=,-t}'[title of your bug]:title: ' \ '(--url= -U)'{--url=,-U}'[URL associated with the bug]:url: ' \ '--priority[priority of this bug]:priority: ' \ '--severity[severity of this bug]:severity: ' } (( ${+functions[_bugz_cmd_search]} )) || _bugz_cmd_search() { # TODO --component,--status,--product,--priority can be specified multiple times _arguments -s : \ '(--assigned-to= -a)'{--assigned-to=,-a}'[the email adress the bug is assigned to]:email: ' \ '--cc=[restrict by CC email address]:email: ' \ '(--comments -c)'{--comments,-c}'[search comments instead of title]:comment: ' \ '(--component= -C)'{--component=,-C}'[restrict by component]:component: ' \ '--help[show help message and exit]' \ '(--keywords= -k)'{--keywords=,-k}'[bug keywords]:keywords: ' \ '--severity=[restrict by severity]:severity: ' \ '--show-status[show bug status]' \ '(--status= -s)'{--status=,-s}'[bug status]:status: ' \ '(--order= -o)'{--order=,-o}'[sort by]:order:((number\:"bug number" assignee\:"assignee field" importance\:"importance field" date\:"last changed"))' \ '--priority=[restrict by priority]:priority: ' \ '--product=[restrict by product]:product: ' \ '(--reporter= -r)'{--reporter=,-r}'[email of the reporter]:email: ' \ '(--whiteboard= -w)'{--whiteboard=,-w}'[status whiteboard]:status whiteboard: ' } _bugz pybugz-0.14/lbugz000077500000000000000000000007201457040153700140340ustar00rootroot00000000000000#!/usr/bin/env python3 """ lbugz: execute bugz from the git repository. This script is primarily used to test pybugz. It works by prepending the directory it is located in to sys.path then importing pybugz and running the main function from that directory. This is based on a patch from Mike Frysinger . """ import os import sys sys.path.insert(0, os.path.dirname(__file__)) from bugz.cli import main if __name__ == "__main__": main() pybugz-0.14/pyproject.toml000066400000000000000000000025101457040153700156760ustar00rootroot00000000000000[build-system] requires = ["flit_core >=3.8,<4"] build-backend = "flit_core.buildapi" [project] name = "pybugz" description = "python interface to bugzilla" readme = "README" license = {file = "LICENSE"} requires-python = ">=3.3" classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Operating System :: Microsoft :: Windows", "Operating System :: Unix", "Programming Language :: Python :: 3 :: Only", ] authors = [ {name = "Alastair Tse", email = "alastair@liquidx.net"}, {name = "Santiago M. Mola", email = "cooldwind@gmail.com"}, {name = "William Hubbs", email = "w.d.hubbs@gmail.com"}, {name = "Mike Gilbert", email = "floppym@gentoo.org"}, {name = "Benjamin Behringer", email = "mail@benjamin-behringer.de"}, {name = "Arthur Zamarin", email = "arthurzam@gentoo.org"}, ] maintainers = [ {name = "William Hubbs", email = "w.d.hubbs@gmail.com"}, {name = "Arthur Zamarin", email = "arthurzam@gentoo.org"}, ] dynamic = ["version"] [project.urls] Homepage = "http://github.com/williamh/pybugz" Source = "http://github.com/williamh/pybugz" [project.scripts] bugz = "bugz.cli:main" [tool.flit.module] name = "bugz" [tool.flit.external-data] directory = "data" [tool.flit.sdist] include = ["lbugz"]