Remove every default argument using [] or {}.
This commit is contained in:
parent
1f9ac730ce
commit
57fb80f1fa
|
@ -1151,7 +1151,7 @@ class ChatControl(ChatControlBase):
|
|||
def print_conversation(self, text, frm='', tim=None, encrypted=False,
|
||||
subject=None, xhtml=None, simple=False, xep0184_id=None,
|
||||
displaymarking=None, msg_log_id=None, correct_id=None,
|
||||
msg_stanza_id=None, additional_data={}):
|
||||
msg_stanza_id=None, additional_data=None):
|
||||
"""
|
||||
Print a line in the conversation
|
||||
|
||||
|
@ -1166,6 +1166,9 @@ class ChatControl(ChatControlBase):
|
|||
"""
|
||||
contact = self.contact
|
||||
|
||||
if additional_data is None:
|
||||
additional_data = {}
|
||||
|
||||
if frm == 'status':
|
||||
if not gajim.config.get('print_status_in_chats'):
|
||||
return
|
||||
|
|
|
@ -737,7 +737,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
|
|||
return label
|
||||
|
||||
def send_message(self, message, keyID='', type_='chat', chatstate=None,
|
||||
msg_id=None, resource=None, xhtml=None, callback=None, callback_args=[],
|
||||
msg_id=None, resource=None, xhtml=None, callback=None, callback_args=None,
|
||||
process_commands=True, attention=False):
|
||||
"""
|
||||
Send the given message to the active tab. Doesn't return None if error
|
||||
|
@ -745,6 +745,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
|
|||
if not message or message == '\n':
|
||||
return None
|
||||
|
||||
if callback_args is None:
|
||||
callback_args = []
|
||||
|
||||
if process_commands and self.process_as_command(message):
|
||||
return
|
||||
|
||||
|
@ -807,7 +810,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
|
|||
other_tags_for_name=[], other_tags_for_time=[], other_tags_for_text=[],
|
||||
count_as_new=True, subject=None, old_kind=None, xhtml=None, simple=False,
|
||||
xep0184_id=None, graphics=True, displaymarking=None, msg_log_id=None,
|
||||
msg_stanza_id=None, correct_id=None, additional_data={}):
|
||||
msg_stanza_id=None, correct_id=None, additional_data=None):
|
||||
"""
|
||||
Print 'chat' type messages
|
||||
correct_id = (message_id, correct_id)
|
||||
|
@ -819,6 +822,15 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
|
|||
if self.was_at_the_end or kind == 'outgoing':
|
||||
end = True
|
||||
|
||||
if other_tags_for_name is None:
|
||||
other_tags_for_name = []
|
||||
if other_tags_for_time is None:
|
||||
other_tags_for_time = []
|
||||
if other_tags_for_text is None:
|
||||
other_tags_for_text = []
|
||||
if additional_data is None:
|
||||
additional_data = {}
|
||||
|
||||
textview.print_conversation_line(text, jid, kind, name, tim,
|
||||
other_tags_for_name, other_tags_for_time, other_tags_for_text,
|
||||
subject, old_kind, xhtml, simple=simple, graphics=graphics,
|
||||
|
|
|
@ -94,13 +94,15 @@ def create_suitable_client_caps(node, caps_hash, hash_method, fjid=None):
|
|||
client_caps = ClientCaps(caps_hash, node, hash_method)
|
||||
return client_caps
|
||||
|
||||
def compute_caps_hash(identities, features, dataforms=[], hash_method='sha-1'):
|
||||
def compute_caps_hash(identities, features, dataforms=None, hash_method='sha-1'):
|
||||
"""
|
||||
Compute caps hash according to XEP-0115, V1.5
|
||||
|
||||
dataforms are nbxmpp.DataForms objects as common.dataforms don't allow several
|
||||
values without a field type list-multi
|
||||
"""
|
||||
if dataforms is None:
|
||||
dataforms = []
|
||||
def sort_identities_func(i1, i2):
|
||||
cat1 = i1['category']
|
||||
cat2 = i2['category']
|
||||
|
|
|
@ -526,7 +526,9 @@ class CommonConnection:
|
|||
subject, type_, msg_iq, xhtml)
|
||||
|
||||
def log_message(self, jid, msg, forward_from, session, original_message,
|
||||
subject, type_, xhtml=None, additional_data={}):
|
||||
subject, type_, xhtml=None, additional_data=None):
|
||||
if additional_data is None:
|
||||
additional_data = {}
|
||||
if not forward_from and session and session.is_loggable():
|
||||
ji = gajim.get_jid_without_resource(jid)
|
||||
if gajim.config.should_log(self.name, ji):
|
||||
|
@ -567,7 +569,7 @@ class CommonConnection:
|
|||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def request_subscription(self, jid, msg='', name='', groups=[],
|
||||
def request_subscription(self, jid, msg='', name='', groups=None,
|
||||
auto_auth=False):
|
||||
"""
|
||||
To be implemented by derivated classes
|
||||
|
@ -2251,10 +2253,12 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
p = nbxmpp.Presence(jid, 'unsubscribe')
|
||||
self.connection.send(p)
|
||||
|
||||
def request_subscription(self, jid, msg='', name='', groups=[],
|
||||
def request_subscription(self, jid, msg='', name='', groups=None,
|
||||
auto_auth=False, user_nick=''):
|
||||
if not gajim.account_is_connected(self.name):
|
||||
return
|
||||
if groups is None:
|
||||
groups = []
|
||||
log.debug('subscription request for %s' % jid)
|
||||
if auto_auth:
|
||||
self.jids_for_auto_auth.append(jid)
|
||||
|
|
|
@ -92,12 +92,14 @@ class Contact(CommonContact):
|
|||
"""
|
||||
Information concerning a contact
|
||||
"""
|
||||
def __init__(self, jid, account, name='', groups=[], show='', status='',
|
||||
def __init__(self, jid, account, name='', groups=None, show='', status='',
|
||||
sub='', ask='', resource='', priority=0, keyID='', client_caps=None,
|
||||
our_chatstate=None, chatstate=None, last_status_time=None, msg_log_id=None,
|
||||
last_activity_time=None):
|
||||
if not isinstance(jid, str):
|
||||
print('no str')
|
||||
if groups is None:
|
||||
groups = []
|
||||
|
||||
CommonContact.__init__(self, jid, account, resource, show, status, name,
|
||||
our_chatstate, chatstate, client_caps=client_caps)
|
||||
|
@ -244,10 +246,12 @@ class LegacyContactsAPI:
|
|||
del self._accounts[account]
|
||||
self._metacontact_manager.remove_account(account)
|
||||
|
||||
def create_contact(self, jid, account, name='', groups=[], show='',
|
||||
def create_contact(self, jid, account, name='', groups=None, show='',
|
||||
status='', sub='', ask='', resource='', priority=0, keyID='',
|
||||
client_caps=None, our_chatstate=None, chatstate=None, last_status_time=None,
|
||||
last_activity_time=None):
|
||||
if groups is None:
|
||||
groups = []
|
||||
# Use Account object if available
|
||||
account = self._accounts.get(account, account)
|
||||
return Contact(jid=jid, account=account, name=name, groups=groups,
|
||||
|
@ -348,12 +352,14 @@ class LegacyContactsAPI:
|
|||
return contact
|
||||
return self.get_highest_prio_contact_from_contacts(contacts)
|
||||
|
||||
def get_nb_online_total_contacts(self, accounts=[], groups=[]):
|
||||
def get_nb_online_total_contacts(self, accounts=None, groups=None):
|
||||
"""
|
||||
Return the number of online contacts and the total number of contacts
|
||||
"""
|
||||
if accounts == []:
|
||||
if not accounts:
|
||||
accounts = self.get_accounts()
|
||||
if groups is None:
|
||||
groups = []
|
||||
nbr_online = 0
|
||||
nbr_total = 0
|
||||
for account in accounts:
|
||||
|
|
|
@ -247,11 +247,13 @@ class Events:
|
|||
event.account = account
|
||||
self.fire_event_added(event)
|
||||
|
||||
def remove_events(self, account, jid, event = None, types = []):
|
||||
def remove_events(self, account, jid, event=None, types=None):
|
||||
"""
|
||||
If event is not specified, remove all events from this jid, optionally
|
||||
only from given type return True if no such event found
|
||||
"""
|
||||
if types is None:
|
||||
types = []
|
||||
if account not in self._events:
|
||||
return True
|
||||
if jid not in self._events[account]:
|
||||
|
@ -297,15 +299,19 @@ class Events:
|
|||
self._events[account][new_jid] = self._events[account][old_jid]
|
||||
del self._events[account][old_jid]
|
||||
|
||||
def get_nb_events(self, types = [], account = None):
|
||||
def get_nb_events(self, types=None, account=None):
|
||||
if types is None:
|
||||
types = []
|
||||
return self._get_nb_events(types = types, account = account)
|
||||
|
||||
def get_events(self, account, jid = None, types = []):
|
||||
def get_events(self, account, jid=None, types=None):
|
||||
"""
|
||||
Return all events from the given account of the form {jid1: [], jid2:
|
||||
[]}. If jid is given, returns all events from the given jid in a list: []
|
||||
optionally only from given type
|
||||
"""
|
||||
if types is None:
|
||||
types = []
|
||||
if account not in self._events:
|
||||
return []
|
||||
if not jid:
|
||||
|
@ -342,11 +348,12 @@ class Events:
|
|||
first_event = event
|
||||
return first_event
|
||||
|
||||
def _get_nb_events(self, account = None, jid = None, attribute = None, types
|
||||
= []):
|
||||
def _get_nb_events(self, account=None, jid=None, attribute=None, types=None):
|
||||
"""
|
||||
Return the number of pending events
|
||||
"""
|
||||
if types is None:
|
||||
types = []
|
||||
nb = 0
|
||||
if account:
|
||||
accounts = [account]
|
||||
|
@ -411,11 +418,13 @@ class Events:
|
|||
first_event = event
|
||||
return first_account, first_jid, first_event
|
||||
|
||||
def get_nb_systray_events(self, types = []):
|
||||
def get_nb_systray_events(self, types=None):
|
||||
"""
|
||||
Return the number of events displayed in roster
|
||||
"""
|
||||
return self._get_nb_events(attribute = 'systray', types = types)
|
||||
if types is None:
|
||||
types = []
|
||||
return self._get_nb_events(attribute='systray', types=types)
|
||||
|
||||
def get_systray_events(self):
|
||||
"""
|
||||
|
@ -428,12 +437,14 @@ class Events:
|
|||
events = self.get_systray_events()
|
||||
return self._get_first_event_with_attribute(events)
|
||||
|
||||
def get_nb_roster_events(self, account = None, jid = None, types = []):
|
||||
def get_nb_roster_events(self, account=None, jid=None, types=None):
|
||||
"""
|
||||
Return the number of events displayed in roster
|
||||
"""
|
||||
return self._get_nb_events(attribute = 'roster', account = account,
|
||||
jid = jid, types = types)
|
||||
if types is None:
|
||||
types = []
|
||||
return self._get_nb_events(attribute='roster', account=account,
|
||||
jid=jid, types=types)
|
||||
|
||||
def get_roster_events(self):
|
||||
"""
|
||||
|
|
|
@ -127,10 +127,12 @@ class JingleContent(object):
|
|||
if candidates:
|
||||
self.add_remote_candidates(candidates)
|
||||
|
||||
def __content(self, payload=[]):
|
||||
def __content(self, payload=None):
|
||||
"""
|
||||
Build a XML content-wrapper for our data
|
||||
"""
|
||||
if payload is None:
|
||||
payload = []
|
||||
return nbxmpp.Node('content',
|
||||
attrs={'name': self.name, 'creator': self.creator},
|
||||
payload=payload)
|
||||
|
|
|
@ -89,9 +89,11 @@ class LocationListener:
|
|||
def shut_down(self):
|
||||
pass
|
||||
|
||||
def _on_geoclue_address_changed(self, timestamp=None, address={},
|
||||
def _on_geoclue_address_changed(self, timestamp=None, address=None,
|
||||
accuracy=None):
|
||||
# update data with info we just received
|
||||
if address is None:
|
||||
address = {}
|
||||
for field in ['country', 'countrycode', 'locality', 'postalcode',
|
||||
'region', 'street']:
|
||||
self._data[field] = address.get(field, None)
|
||||
|
@ -102,8 +104,10 @@ class LocationListener:
|
|||
self._data['accuracy'] = accuracy[1]
|
||||
self._send_location()
|
||||
|
||||
def _on_geoclue_position_changed(self, fields=[], timestamp=None, lat=None,
|
||||
def _on_geoclue_position_changed(self, fields=None, timestamp=None, lat=None,
|
||||
lon=None, alt=None, accuracy=None):
|
||||
if fields is None:
|
||||
fields = []
|
||||
# update data with info we just received
|
||||
_dict = {'lat': lat, 'lon': lon, 'alt': alt}
|
||||
for field in _dict:
|
||||
|
|
|
@ -490,7 +490,7 @@ class Logger:
|
|||
all_messages.append(results[0])
|
||||
return all_messages
|
||||
|
||||
def write(self, kind, jid, message=None, show=None, tim=None, subject=None, additional_data={}):
|
||||
def write(self, kind, jid, message=None, show=None, tim=None, subject=None, additional_data=None):
|
||||
"""
|
||||
Write a row (status, gcstatus, message etc) to logs database
|
||||
|
||||
|
@ -504,6 +504,8 @@ class Logger:
|
|||
ROOM_JID/nick if pm-related.
|
||||
"""
|
||||
|
||||
if additional_data is None:
|
||||
additional_data = {}
|
||||
if self.jids_already_in == []: # only happens if we just created the db
|
||||
self.open_db()
|
||||
|
||||
|
@ -1101,7 +1103,9 @@ class Logger:
|
|||
(account_jid_id,))
|
||||
self._timeout_commit()
|
||||
|
||||
def save_if_not_exists(self, with_, direction, tim, msg='', nick=None, additional_data={}):
|
||||
def save_if_not_exists(self, with_, direction, tim, msg='', nick=None, additional_data=None):
|
||||
if additional_data is None:
|
||||
additional_data = {}
|
||||
if tim:
|
||||
time_col = float(tim)
|
||||
else:
|
||||
|
|
|
@ -241,7 +241,8 @@ class OptionsParser:
|
|||
|
||||
caps_cache.capscache.initialize_from_db()
|
||||
|
||||
def assert_unread_msgs_table_exists(self):
|
||||
@staticmethod
|
||||
def assert_unread_msgs_table_exists():
|
||||
"""
|
||||
Create table unread_messages if there is no such table
|
||||
"""
|
||||
|
@ -265,7 +266,12 @@ class OptionsParser:
|
|||
pass
|
||||
con.close()
|
||||
|
||||
def update_ft_proxies(self, to_remove=[], to_add=[]):
|
||||
@staticmethod
|
||||
def update_ft_proxies(to_remove=None, to_add=None):
|
||||
if to_remove is None:
|
||||
to_remove = []
|
||||
if to_add is None:
|
||||
to_add = []
|
||||
for account in gajim.config.get_per('accounts'):
|
||||
proxies_str = gajim.config.get_per('accounts', account,
|
||||
'file_transfer_proxies')
|
||||
|
|
|
@ -62,7 +62,9 @@ else:
|
|||
should return the validated text, or raise ValueError
|
||||
"""
|
||||
def uri_reference_role(role, rawtext, text, lineno, inliner,
|
||||
options={}, content=[]):
|
||||
options=None, content=None):
|
||||
if options is None:
|
||||
options = {}
|
||||
try:
|
||||
valid_text = validator(text)
|
||||
except ValueError as e:
|
||||
|
@ -102,9 +104,10 @@ else:
|
|||
It reuses the docutils.core.Publisher class, which means it is *not*
|
||||
threadsafe.
|
||||
"""
|
||||
def __init__(self, settings_spec=None,
|
||||
settings_overrides=dict(report_level=5, halt_level=5),
|
||||
def __init__(self, settings_spec=None, settings_overrides=None,
|
||||
config_section='general'):
|
||||
if settings_overrides is None:
|
||||
settings_overrides = {'report_level': 5, 'halt_level': 5}
|
||||
self.pub = Publisher(reader=None, parser=None, writer=None,
|
||||
settings=None,
|
||||
source_class=io.StringInput,
|
||||
|
|
|
@ -448,9 +448,10 @@ class ConversationTextview(GObject.GObject):
|
|||
self.auto_scrolling = False
|
||||
return False # when called in an idle_add, just do it once
|
||||
|
||||
def bring_scroll_to_end(self, diff_y = 0,
|
||||
use_smooth=gajim.config.get('use_smooth_scrolling')):
|
||||
def bring_scroll_to_end(self, diff_y=0, use_smooth=None):
|
||||
''' scrolls to the end of textview if end is not visible '''
|
||||
if use_smooth is None:
|
||||
use_smooth = gajim.config.get('use_smooth_scrolling')
|
||||
buffer_ = self.tv.get_buffer()
|
||||
end_iter = buffer_.get_end_iter()
|
||||
end_rect = self.tv.get_iter_location(end_iter)
|
||||
|
@ -1014,7 +1015,7 @@ class ConversationTextview(GObject.GObject):
|
|||
helpers.launch_browser_mailer(kind, word)
|
||||
|
||||
def detect_and_print_special_text(self, otext, other_tags, graphics=True,
|
||||
iter_=None, additional_data={}):
|
||||
iter_=None, additional_data=None):
|
||||
"""
|
||||
Detect special text (emots & links & formatting), print normal text
|
||||
before any special text it founds, then print special text (that happens
|
||||
|
@ -1024,6 +1025,8 @@ class ConversationTextview(GObject.GObject):
|
|||
"""
|
||||
if not otext:
|
||||
return
|
||||
if additional_data is None:
|
||||
additional_data = {}
|
||||
buffer_ = self.tv.get_buffer()
|
||||
if other_tags:
|
||||
insert_tags_func = buffer_.insert_with_tags_by_name
|
||||
|
@ -1079,11 +1082,13 @@ class ConversationTextview(GObject.GObject):
|
|||
return end_iter
|
||||
|
||||
def print_special_text(self, special_text, other_tags, graphics=True,
|
||||
iter_=None, additional_data={}):
|
||||
iter_=None, additional_data=None):
|
||||
"""
|
||||
Is called by detect_and_print_special_text and prints special text
|
||||
(emots, links, formatting)
|
||||
"""
|
||||
if additional_data is None:
|
||||
additional_data = {}
|
||||
|
||||
# PluginSystem: adding GUI extension point for ConversationTextview
|
||||
self.plugin_modified = False
|
||||
|
@ -1538,10 +1543,12 @@ class ConversationTextview(GObject.GObject):
|
|||
self.print_empty_line(end_iter)
|
||||
|
||||
def print_real_text(self, text, text_tags=[], name=None, xhtml=None,
|
||||
graphics=True, mark=None, additional_data={}):
|
||||
graphics=True, mark=None, additional_data=None):
|
||||
"""
|
||||
Add normal and special text. call this to add text
|
||||
"""
|
||||
if additional_data is None:
|
||||
additional_data = {}
|
||||
buffer_ = self.tv.get_buffer()
|
||||
if not mark:
|
||||
iter_ = buffer_.get_end_iter()
|
||||
|
|
10
src/disco.py
10
src/disco.py
|
@ -299,10 +299,12 @@ class ServicesCache:
|
|||
if not self._cbs[cbkey]:
|
||||
del self._cbs[cbkey]
|
||||
|
||||
def get_icon(self, identities = [], addr=''):
|
||||
def get_icon(self, identities=None, addr=''):
|
||||
"""
|
||||
Return the icon for an agent
|
||||
"""
|
||||
if identities is None:
|
||||
identities = []
|
||||
# Grab the first identity with an icon
|
||||
quiet = False
|
||||
for identity in identities:
|
||||
|
@ -334,10 +336,14 @@ class ServicesCache:
|
|||
_icon_cache['jabber'] = pix
|
||||
return pix
|
||||
|
||||
def get_browser(self, identities=[], features=[]):
|
||||
def get_browser(self, identities=None, features=None):
|
||||
"""
|
||||
Return the browser class for an agent
|
||||
"""
|
||||
if identities is None:
|
||||
identities = []
|
||||
if features is None:
|
||||
features = []
|
||||
# First pass, we try to find a ToplevelAgentBrowser
|
||||
for identity in identities:
|
||||
try:
|
||||
|
|
|
@ -59,13 +59,15 @@ def build_resources_submenu(contacts, account, action, room_jid=None,
|
|||
|
||||
return sub_menu
|
||||
|
||||
def build_invite_submenu(invite_menuitem, list_, ignore_rooms=[],
|
||||
def build_invite_submenu(invite_menuitem, list_, ignore_rooms=None,
|
||||
show_bookmarked=False, force_resource=False):
|
||||
"""
|
||||
list_ in a list of (contact, account)
|
||||
force_resource means we want to send invitation even if there is only one
|
||||
resource
|
||||
"""
|
||||
if ignore_rooms is None:
|
||||
ignore_rooms = []
|
||||
roster = gajim.interface.roster
|
||||
# used if we invite only one contact with several resources
|
||||
contact_list = []
|
||||
|
|
|
@ -267,13 +267,16 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
|||
|
||||
def roster_message(self, jid, msg, tim, encrypted=False, msg_type='',
|
||||
subject=None, resource='', msg_log_id=None, user_nick='', xhtml=None,
|
||||
form_node=None, displaymarking=None, additional_data={}):
|
||||
form_node=None, displaymarking=None, additional_data=None):
|
||||
"""
|
||||
Display the message or show notification in the roster
|
||||
"""
|
||||
contact = None
|
||||
fjid = jid
|
||||
|
||||
if additional_data is None:
|
||||
additional_data = {}
|
||||
|
||||
# Try to catch the contact with correct resource
|
||||
if resource:
|
||||
fjid = jid + '/' + resource
|
||||
|
|
Loading…
Reference in New Issue