Package pybaz :: Module _my_id
[frames] | no frames]

Source Code for Module pybaz._my_id

 1  # arch-tag: c97e5e20-4852-44eb-b896-7442a39023fc 
 2  # Copyright (C) 2003 David Allouche <david@allouche.net> 
 3  # 
 4  #    This program is free software; you can redistribute it and/or modify 
 5  #    it under the terms of the GNU General Public License as published by 
 6  #    the Free Software Foundation; either version 2 of the License, or 
 7  #    (at your option) any later version. 
 8  # 
 9  #    This program is distributed in the hope that it will be useful, 
10  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
11  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
12  #    GNU General Public License for more details. 
13  # 
14  #    You should have received a copy of the GNU General Public License 
15  #    along with this program; if not, write to the Free Software 
16  #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
17   
18  """Internal module providing my-id getting and setting. 
19   
20  This module implements some of public interface for the 
21  pybaz_ package. But for convenience reasons the author prefers 
22  to store this code in a file separate from ``__init__.py``. 
23   
24  .. _pybaz: pybaz-module.html 
25   
26  This module is strictly internal and should never be used. 
27  """ 
28   
29  __all__ = ['my_id', 'set_my_id'] 
30   
31   
32 -def _backend():
33 import pybaz 34 return pybaz.backend
35 36
37 -def my_id():
38 """The current registered user id 39 40 :return: the user id, for example 'John Doe <jdoe@example.org>'. 41 :rtype: str 42 """ 43 status, output = _backend().status_one_cmd(('my-id',), (0,2)) 44 # status is 2 if the user id is not set. 45 # maybe an exception should be thrown instead of returning None. 46 if status != 0: return None 47 return output
48
49 -def set_my_id(new_id):
50 """Set the current registered user id 51 52 :param new_id: new value of the user id. 53 :type new_id: str 54 """ 55 _backend().null_cmd(('my-id', new_id))
56