code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
self.framecolor = color
self.canvas.figure.set_facecolor(color)
if callable(self.theme_color_callback):
self.theme_color_callback(color, 'frame') | def set_framecolor(self, color) | set color for outer frame | 4.518686 | 4.367214 | 1.034684 |
self.textcolor = color
self.relabel()
if callable(self.theme_color_callback):
self.theme_color_callback(color, 'text') | def set_textcolor(self, color) | set color for labels and axis text | 6.442337 | 6.486112 | 0.993251 |
"enable/disable grid display"
if show is not None:
self.show_grid = show
axes = self.canvas.figure.get_axes()
ax0 = axes[0]
for i in ax0.get_xgridlines() + ax0.get_ygridlines():
i.set_color(self.gridcolor)
i.set_zorder(-1)
axes[0].grid(... | def enable_grid(self, show=None, delay_draw=False) | enable/disable grid display | 2.492783 | 2.456443 | 1.014794 |
if style is not None:
self.axes_style = style
axes0 = self.canvas.figure.get_axes()[0]
_sty = self.axes_style.lower()
if _sty in ('fullbox', 'full'):
_sty = 'box'
if _sty == 'leftbot':
_sty = 'open'
if _sty == 'box':
... | def set_axes_style(self, style=None, delay_draw=False) | set axes style: one of
'box' / 'fullbox' : show all four axes borders
'open' / 'leftbot' : show left and bottom axes
'bottom' : show bottom axes only | 1.9301 | 1.652609 | 1.167911 |
"redraw the legend"
if show is not None:
self.show_legend = show
axes = self.canvas.figure.get_axes()
# clear existing legend
try:
lgn = self.mpl_legend
if lgn:
for i in lgn.get_texts():
i.set_text('')
... | def draw_legend(self, show=None, auto_location=True, delay_draw=False) | redraw the legend | 2.945555 | 2.946103 | 0.999814 |
"set legend location"
self.legend_onaxis = 'on plot'
if not onaxis:
self.legend_onaxis = 'off plot'
if loc == 'best':
loc = 'upper right'
if loc in self.legend_abbrevs:
loc = self.legend_abbrevs[loc]
if loc in self.legend_locs:
... | def set_legend_location(self, loc, onaxis) | set legend location | 3.14145 | 3.212459 | 0.977896 |
if full:
self.zoom_lims = self.zoom_lims[:1]
self.zoom_lims = []
elif len(self.zoom_lims) > 0:
self.zoom_lims.pop()
self.set_viewlimits()
if not delay_draw:
self.canvas.draw() | def unzoom(self, full=False, delay_draw=False) | unzoom display 1 level or all the way | 2.949585 | 2.906174 | 1.014938 |
"set log or linear scale for x, y axis"
self.xscale = xscale
self.yscale = yscale
for axes in self.canvas.figure.get_axes():
try:
axes.set_yscale(yscale, basey=10)
except:
axes.set_yscale('linear')
try:
a... | def set_logscale(self, xscale='linear', yscale='linear',
delay_draw=False) | set log or linear scale for x, y axis | 2.364122 | 2.223128 | 1.063421 |
self.panel.add_text(text, x, y, **kws) | def add_text(self, text, x, y, **kws) | add text to plot | 3.655553 | 3.272281 | 1.117127 |
self.panel.add_arrow(x1, y1, x2, y2, **kws) | def add_arrow(self, x1, y1, x2, y2, **kws) | add arrow to plot | 2.820895 | 2.489509 | 1.133113 |
self.panel.plot(x, y, **kw) | def plot(self, x, y, **kw) | plot after clearing current plot | 6.027628 | 5.091598 | 1.183838 |
self.panel.oplot(x, y, **kw) | def oplot(self, x, y, **kw) | generic plotting method, overplotting any existing plot | 6.018588 | 5.381509 | 1.118383 |
self.panel.scatterplot(x, y, **kw) | def scatterplot(self, x, y, **kw) | plot after clearing current plot | 5.71841 | 5.036945 | 1.135293 |
self.panel.update_line(t, x, y, **kw) | def update_line(self, t, x, y, **kw) | overwrite data for trace t | 3.86063 | 4.407737 | 0.875876 |
"save plot data to external file"
buff = ["# Plot Data for %s" % title,
"#---------------------------------"]
out = []
labels = []
itrace = 0
for ax in self.panel.fig.get_axes():
for line in ax.lines:
itrace += 1
... | def ExportTextFile(self, fname, title='unknown plot') | save plot data to external file | 3.815028 | 3.750215 | 1.017283 |
self.directory_manager.add_directories(paths, except_blacklisted) | def add_plugin_directories(self, paths, except_blacklisted=True) | Adds `directories` to the set of plugin directories.
`directories` may be either a single object or a iterable.
`directories` can be relative paths, but will be converted into
absolute paths based on the current working directory.
if `except_blacklisted` is `True` all `directories` in... | 5.238479 | 7.758535 | 0.675189 |
self.directory_manager.set_directories(paths, except_blacklisted) | def set_plugin_directories(self, paths, except_blacklisted=True) | Sets the plugin directories to `directories`. This will delete
the previous state stored in `self.plugin_directories` in favor
of the `directories` passed in.
`directories` may be either a single object or an iterable.
`directories` can contain relative paths but will be
conver... | 5.212357 | 7.843499 | 0.664545 |
self.file_manager.add_plugin_filepaths(filepaths,
except_blacklisted) | def add_plugin_filepaths(self, filepaths, except_blacklisted=True) | Adds `filepaths` to internal state. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable
If `except_blacklisted` is `True`, all `filepaths` that
have been blacklisted... | 4.611406 | 5.759712 | 0.800631 |
self.file_manager.set_plugin_filepaths(filepaths,
except_blacklisted) | def set_plugin_filepaths(self, filepaths, except_blacklisted=True) | Sets internal state to `filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable.
If `except_blacklisted` is `True`, all `filepaths` that
have been blackliste... | 4.495077 | 5.934521 | 0.757446 |
add_black_dirs = self.directory_manager.add_blacklisted_directories
add_black_dirs(directories, rm_black_dirs_from_stored_dirs) | def add_blacklisted_directories(self,
directories,
rm_black_dirs_from_stored_dirs=True) | Adds `directories` to be blacklisted. Blacklisted directories will not
be returned or searched recursively when calling the
`collect_directories` method.
`directories` may be a single instance or an iterable. Recommend
passing in absolute paths, but method will try to convert to absolut... | 2.907102 | 3.926572 | 0.740366 |
set_black_dirs = self.directory_manager.set_blacklisted_directories
set_black_dirs(directories, rm_black_dirs_from_stored_dirs) | def set_blacklisted_directories(self,
directories,
rm_black_dirs_from_stored_dirs=True) | Sets the `directories` to be blacklisted. Blacklisted directories will
not be returned or searched recursively when calling
`collect_directories`.
This will replace the previously stored set of blacklisted
paths.
`directories` may be a single instance or an iterable. Recommend
... | 2.860713 | 4.073647 | 0.702249 |
self.file_manager.add_blacklisted_filepaths(filepaths,
remove_from_stored) | def add_blacklisted_filepaths(self, filepaths, remove_from_stored=True) | Add `filepaths` to blacklisted filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
internal state will be automatically removed. | 3.896928 | 3.577969 | 1.089145 |
plugin_filepaths = set()
directories = util.to_absolute_paths(directories)
for directory in directories:
filepaths = util.get_filepaths_from_dir(directory)
filepaths = self._filter_filepaths(filepaths)
plugin_filepaths.update(set(filepaths))
... | def collect_filepaths(self, directories) | Collects and returns every filepath from each directory in
`directories` that is filtered through the `file_filters`.
If no `file_filters` are present, passes every file in directory
as a result.
Always returns a `set` object
`directories` can be a object or an iterable. Recomme... | 2.992419 | 3.18959 | 0.938183 |
filepaths = util.to_absolute_paths(filepaths)
if except_blacklisted:
filepaths = util.remove_from_set(filepaths,
self.blacklisted_filepaths)
self.plugin_filepaths.update(filepaths) | def add_plugin_filepaths(self, filepaths, except_blacklisted=True) | Adds `filepaths` to the `self.plugin_filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable
If `except_blacklisted` is `True`, all `filepaths` that
have bee... | 3.326776 | 3.104859 | 1.071474 |
filepaths = util.to_absolute_paths(filepaths)
if except_blacklisted:
filepaths = util.remove_from_set(filepaths,
self.blacklisted_filepaths)
self.plugin_filepaths = filepaths | def set_plugin_filepaths(self, filepaths, except_blacklisted=True) | Sets `filepaths` to the `self.plugin_filepaths`. Recommend passing
in absolute filepaths. Method will attempt to convert to
absolute paths if they are not already.
`filepaths` can be a single object or an iterable.
If `except_blacklisted` is `True`, all `filepaths` that
have be... | 3.428779 | 3.309594 | 1.036012 |
filepaths = util.to_absolute_paths(filepaths)
self.plugin_filepaths = util.remove_from_set(self.plugin_filepaths,
filepaths) | def remove_plugin_filepaths(self, filepaths) | Removes `filepaths` from `self.plugin_filepaths`.
Recommend passing in absolute filepaths. Method will
attempt to convert to absolute paths if not passed in.
`filepaths` can be a single object or an iterable. | 3.874997 | 3.70858 | 1.044874 |
file_filters = util.return_list(file_filters)
self.file_filters = file_filters | def set_file_filters(self, file_filters) | Sets internal file filters to `file_filters` by tossing old state.
`file_filters` can be single object or iterable. | 4.784116 | 5.419839 | 0.882704 |
file_filters = util.return_list(file_filters)
self.file_filters.extend(file_filters) | def add_file_filters(self, file_filters) | Adds `file_filters` to the internal file filters.
`file_filters` can be single object or iterable. | 4.210402 | 4.661718 | 0.903187 |
self.file_filters = util.remove_from_list(self.file_filters,
file_filters) | def remove_file_filters(self, file_filters) | Removes the `file_filters` from the internal state.
`file_filters` can be a single object or an iterable. | 3.913423 | 3.615916 | 1.082277 |
filepaths = util.to_absolute_paths(filepaths)
self.blacklisted_filepaths.update(filepaths)
if remove_from_stored:
self.plugin_filepaths = util.remove_from_set(self.plugin_filepaths,
filepaths) | def add_blacklisted_filepaths(self, filepaths, remove_from_stored=True) | Add `filepaths` to blacklisted filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
`plugin_filepaths` will be automatically removed.
Recommend passing in absolute filepaths but method will attempt
to convert to absolute filepaths based on current working directory. | 3.190187 | 2.536689 | 1.257619 |
filepaths = util.to_absolute_paths(filepaths)
self.blacklisted_filepaths = filepaths
if remove_from_stored:
self.plugin_filepaths = util.remove_from_set(self.plugin_filepaths,
filepaths) | def set_blacklisted_filepaths(self, filepaths, remove_from_stored=True) | Sets internal blacklisted filepaths to filepaths.
If `remove_from_stored` is `True`, any `filepaths` in
`self.plugin_filepaths` will be automatically removed.
Recommend passing in absolute filepaths but method will attempt
to convert to absolute filepaths based on current working direct... | 3.271803 | 2.482685 | 1.317849 |
filepaths = util.to_absolute_paths(filepaths)
black_paths = self.blacklisted_filepaths
black_paths = util.remove_from_set(black_paths, filepaths) | def remove_blacklisted_filepaths(self, filepaths) | Removes `filepaths` from blacklisted filepaths
Recommend passing in absolute filepaths but method will attempt
to convert to absolute filepaths based on current working directory. | 4.353478 | 3.507756 | 1.241101 |
filepaths = util.remove_from_set(filepaths, self.blacklisted_filepaths)
return filepaths | def _remove_blacklisted(self, filepaths) | internal helper method to remove the blacklisted filepaths
from `filepaths`. | 4.588643 | 4.230269 | 1.084717 |
if self.file_filters:
plugin_filepaths = set()
for file_filter in self.file_filters:
plugin_paths = file_filter(filepaths)
plugin_filepaths.update(plugin_paths)
else:
plugin_filepaths = filepaths
return plugin_filepath... | def _filter_filepaths(self, filepaths) | helps iterate through all the file parsers
each filter is applied individually to the
same set of `filepaths` | 2.776213 | 2.567389 | 1.081337 |
if panel is None:
panel = self.current_panel
opts = {}
opts.update(self.default_panelopts)
opts.update(kws)
self.panels[panel].plot(x ,y, **opts) | def plot(self,x,y,panel=None,**kws) | plot after clearing current plot | 3.913475 | 3.820102 | 1.024443 |
if panel is None:
panel = self.current_panel
opts = {}
opts.update(self.default_panelopts)
opts.update(kws)
self.panels[panel].oplot(x, y, **opts) | def oplot(self,x,y,panel=None,**kw) | generic plotting method, overplotting any existing plot | 3.872066 | 3.996696 | 0.968817 |
if panel is None:
panel = self.current_panel
self.panels[panel].update_line(t, x, y, **kw) | def update_line(self, t, x, y, panel=None, **kw) | overwrite data for trace t | 2.375256 | 2.344565 | 1.01309 |
if panel is None: panel = self.current_panel
self.panels[panel].set_xylims(lims, axes=axes, **kw) | def set_xylims(self, lims, axes=None, panel=None) | overwrite data for trace t | 3.29182 | 3.102382 | 1.061062 |
if panel is None: panel = self.current_panel
self.panels[panel].clear() | def clear(self,panel=None) | clear plot | 3.819485 | 3.967405 | 0.962716 |
if panel is None: panel = self.current_panel
self.panels[panel].unzoom_all(event=event) | def unzoom_all(self,event=None,panel=None) | zoom out full data range | 3.604488 | 3.530328 | 1.021007 |
if panel is None: panel = self.current_panel
self.panels[panel].unzoom(event=event) | def unzoom(self,event=None,panel=None) | zoom out 1 level, or to full data range | 3.833099 | 4.008268 | 0.956298 |
"set plot title"
if panel is None: panel = self.current_panel
self.panels[panel].set_title(s) | def set_title(self,s,panel=None) | set plot title | 4.093886 | 4.054096 | 1.009815 |
"set plot xlabel"
if panel is None: panel = self.current_panel
self.panels[panel].set_xlabel(s) | def set_xlabel(self,s,panel=None) | set plot xlabel | 4.301896 | 3.798666 | 1.132475 |
"set plot xlabel"
if panel is None: panel = self.current_panel
self.panels[panel].set_ylabel(s) | def set_ylabel(self,s,panel=None) | set plot xlabel | 4.948018 | 3.868085 | 1.279191 |
if panel is None: panel = self.current_panel
self.panels[panel].save_figure(event=event) | def save_figure(self,event=None,panel=None) | save figure image to file | 3.450147 | 3.439267 | 1.003163 |
c = color.lower()
if c[0:1] == '#' and len(c)==7:
r,g,b = c[1:3], c[3:5], c[5:]
r,g,b = [int(n, 16) for n in (r, g, b)]
return (r,g,b)
if c.find(' ')>-1: c = c.replace(' ','')
if c.find('gray')>-1: c = c.replace('gray','grey')
if c in x11_colors.keys(): return x11_c... | def rgb(color,default=(0,0,0)) | return rgb tuple for named color in rgb.txt or a hex color | 2.515637 | 2.391676 | 1.05183 |
" returns hex color given a tuple, wx.Color, or X11 named color"
# first, if this is a hex color already, return!
# Python 3: needs rewrite for str/unicode change
if isinstance(color, six.string_types):
if color[0] == '#' and len(color)==7:
return color.lower()
# now, get color ... | def hexcolor(color) | returns hex color given a tuple, wx.Color, or X11 named color | 3.597288 | 3.171764 | 1.13416 |
if not HAS_MPL:
return ()
makemap = LinearSegmentedColormap.from_list
for name, val in custom_colormap_data.items():
cm1 = np.array(val).transpose().astype('f8')/256.0
cm2 = cm1[::-1]
nam1 = name
nam2 = '%s_r' % name
register_cmap(name=nam1, cmap=makemap(... | def register_custom_colormaps() | registers custom color maps | 3.696864 | 3.635183 | 1.016968 |
panel = self.get_panel('top')
panel.plot(x, y1, label=label1, **kws)
panel = self.get_panel('top')
panel.oplot(x, y2, label=label2, ylabel=ylabel, show_legend=show_legend, **kws)
panel = self.get_panel('bottom')
panel.plot(x, (y2-y1), ylabel='residual', show_leg... | def plot_residual(self, x, y1, y2, label1='Raw data', label2='Fit/theory',
xlabel=None, ylabel=None, show_legend=True,
**kws) | plot after clearing current plot | 2.602186 | 2.609531 | 0.997185 |
if title is not None:
self.SetTitle(title)
if subtitles is not None:
self.subtitles = subtitles
cmode = self.config_mode.lower()[:3]
img = np.array(img)
if len(img.shape) == 3:
ishape = img.shape
# make sure 3d image is sh... | def display(self, img, title=None, colormap=None, style='image',
subtitles=None, auto_contrast=False, contrast_level=None, **kws) | display image | 2.901147 | 2.895028 | 1.002114 |
panel = self.config_panel
sizer = wx.BoxSizer(wx.VERTICAL)
lsty = wx.ALIGN_LEFT|wx.LEFT|wx.TOP|wx.EXPAND
if self.config_mode == 'rgb':
for icol, col in enumerate(RGB_COLORS):
self.cmap_panels[icol] = ColorMapPanel(self.config_panel,
... | def Build_ConfigPanel(self) | config panel for left-hand-side of frame: RGB Maps | 2.19671 | 2.16069 | 1.016671 |
if contrast_level is None:
clevel = self.contrast_panel.choice.GetStringSelection()
if clevel == 'None':
contrast_level = 0
else:
contrast_level = float(clevel)
conf = self.panel.conf
img = self.panel.conf.data
... | def set_contrast_levels(self, contrast_level=None) | enhance contrast levels, or use full data range
according to value of self.panel.conf.contrast_level | 2.005921 | 1.971407 | 1.017507 |
file_choices = 'PNG (*.png)|*.png'
ofile = 'Colormap.png'
dlg = wx.FileDialog(self, message='Save Colormap as...',
defaultDir=os.getcwd(),
defaultFile=ofile,
wildcard=file_choices,
... | def onCMapSave(self, event=None, col='int') | save color table image | 2.551759 | 2.402157 | 1.062278 |
if self.panel is not None:
self.panel.save_figure(event=event,
transparent=transparent, dpi=dpi) | def save_figure(self,event=None, transparent=True, dpi=600) | save figure image to file | 3.352574 | 3.49321 | 0.95974 |
filename = os.path.basename(filename)
for regex in self.regex_expressions:
if regex.match(filename):
return True
return False | def plugin_valid(self, filename) | Checks if the given filename is a valid plugin for this Strategy | 3.858459 | 3.720205 | 1.037163 |
if self._auto_reply is None:
r = requests.get('https://outlook.office.com/api/v2.0/me/MailboxSettings/AutomaticRepliesSetting',
headers=self._headers)
check_response(r)
self._auto_reply = r.json().get('InternalReplyMessage')
retu... | def auto_reply_message(self) | The account's Internal auto reply message. Setting the value will change the auto reply message of the
account, automatically setting the status to enabled (but not altering the schedule). | 4.832737 | 3.959079 | 1.220672 |
# type: (str, OutlookAccount.AutoReplyStatus, datetime, datetime, str, OutlookAccount.AutoReplyAudience) -> None
start_is_none = start is None
end_is_none = end is None
if (not start_is_none and end_is_none) or (start_is_none and not end_is_none):
raise ValueError(... | def set_auto_reply(self, message, status=AutoReplyStatus.ALWAYS_ENABLED, start=None, end=None,
external_message=None, audience=AutoReplyAudience.ALL) | Set an automatic reply for the account.
Args:
message (str): The message to be sent in replies. If external_message is provided this is the message sent
to internal recipients
status (OutlookAccount.AutoReplyStatus): Whether the auto-reply should be always enabled, scheduled,... | 2.815727 | 2.884339 | 0.976212 |
r = requests.get('https://outlook.office.com/api/v2.0/me/messages/' + message_id, headers=self._headers)
check_response(r)
return Message._json_to_message(self, r.json()) | def get_message(self, message_id) | Gets message matching provided id.
the Outlook email matching the provided message_id.
Args:
message_id: A string for the intended message, provided by Outlook
Returns:
:class:`Message <pyOutlook.core.message.Message>` | 3.334781 | 3.530601 | 0.944536 |
endpoint = 'https://outlook.office.com/api/v2.0/me/messages'
if page > 0:
endpoint = endpoint + '/?%24skip=' + str(page) + '0'
log.debug('Getting messages from endpoint: {} with Headers: {}'.format(endpoint, self._headers))
r = requests.get(endpoint, headers=self._... | def get_messages(self, page=0) | Get first 10 messages in account, across all folders.
Keyword Args:
page (int): Integer representing the 'page' of results to fetch
Returns:
List[:class:`Message <pyOutlook.core.message.Message>`] | 3.763835 | 3.686079 | 1.021095 |
return Message(self.access_token, body, subject, to) | def new_email(self, body='', subject='', to=list) | Creates a :class:`Message <pyOutlook.core.message.Message>` object.
Keyword Args:
body (str): The body of the email
subject (str): The subject of the email
to (List[Contact]): A list of recipients to email
Returns:
:class:`Message <pyOutlook.core.message... | 8.809088 | 15.009822 | 0.586888 |
email = Message(self.access_token, body, subject, to, cc=cc, bcc=bcc, sender=send_as)
if attachments is not None:
for attachment in attachments:
email.attach(attachment.get('bytes'), attachment.get('name'))
email.send() | def send_email(self, body=None, subject=None, to=list, cc=None, bcc=None,
send_as=None, attachments=None) | Sends an email in one method, a shortcut for creating an instance of
:class:`Message <pyOutlook.core.message.Message>` .
Args:
body (str): The body of the email
subject (str): The subject of the email
to (list): A list of :class:`Contacts <pyOutlook.core.contact.Cont... | 3.24072 | 3.409504 | 0.950496 |
endpoint = 'https://outlook.office.com/api/v2.0/me/MailFolders/'
r = requests.get(endpoint, headers=self._headers)
if check_response(r):
return Folder._json_to_folders(self, r.json()) | def get_folders(self) | Returns a list of all folders for this account
Returns:
List[:class:`Folder <pyOutlook.core.folder.Folder>`] | 4.691918 | 3.926402 | 1.194966 |
endpoint = 'https://outlook.office.com/api/v2.0/me/MailFolders/' + folder_id
r = requests.get(endpoint, headers=self._headers)
check_response(r)
return_folder = r.json()
return Folder._json_to_folder(self, return_folder) | def get_folder_by_id(self, folder_id) | Retrieve a Folder by its Outlook ID
Args:
folder_id: The ID of the :class:`Folder <pyOutlook.core.folder.Folder>` to retrieve
Returns: :class:`Folder <pyOutlook.core.folder.Folder>` | 3.681485 | 3.50435 | 1.050547 |
r = requests.get('https://outlook.office.com/api/v2.0/me/MailFolders/' + folder_name + '/messages',
headers=self._headers)
check_response(r)
return Message._json_to_messages(self, r.json()) | def _get_messages_from_folder_name(self, folder_name) | Retrieves all messages from a folder, specified by its name. This only works with "Well Known" folders,
such as 'Inbox' or 'Drafts'.
Args:
folder_name (str): The name of the folder to retrieve
Returns: List[:class:`Message <pyOutlook.core.message.Message>` ] | 3.446958 | 3.453852 | 0.998004 |
# type: () -> Folder
if self.__parent_folder is None:
self.__parent_folder = self.account.get_folder_by_id(self.__parent_folder_id)
return self.__parent_folder | def parent_folder(self) | Returns the :class:`Folder <pyOutlook.core.folder.Folder>` this message is in
>>> account = OutlookAccount('')
>>> message = account.get_messages()[0]
>>> message.parent_folder
Inbox
>>> message.parent_folder.unread_count
19
Returns: :cla... | 3.317202 | 4.701488 | 0.705564 |
payload = dict(Subject=self.subject, Body=dict(ContentType=content_type, Content=self.body))
if self.sender is not None:
payload.update(From=self.sender.api_representation())
# A list of strings can also be provided for convenience. If provided, convert them into Contacts
... | def api_representation(self, content_type) | Returns the JSON representation of this message required for making requests to the API.
Args:
content_type (str): Either 'HTML' or 'Text' | 2.547481 | 2.544659 | 1.001109 |
# type: (str, str, dict, Any) -> None
headers = {"Authorization": "Bearer " + self.account.access_token, "Content-Type": "application/json"}
if extra_headers is not None:
headers.update(extra_headers)
log.debug('Making Outlook API request for message (ID: {}) with... | def _make_api_call(self, http_type, endpoint, extra_headers = None, data=None) | Internal method to handle making calls to the Outlook API and logging both the request and response
Args:
http_type: (str) 'post' or 'delete'
endpoint: (str) The endpoint the request will be made to
headers: A dict of headers to send to the requests module in addition to Auth... | 2.546796 | 2.873291 | 0.886369 |
payload = self.api_representation(content_type)
endpoint = 'https://outlook.office.com/api/v1.0/me/sendmail'
self._make_api_call('post', endpoint=endpoint, data=json.dumps(payload)) | def send(self, content_type='HTML') | Takes the recipients, body, and attachments of the Message and sends.
Args:
content_type: Can either be 'HTML' or 'Text', defaults to HTML. | 5.071027 | 4.96703 | 1.020938 |
# type: (Union[List[Contact], List[str]], str) -> None
payload = dict()
if forward_comment is not None:
payload.update(Comment=forward_comment)
# A list of strings can also be provided for convenience. If provided, convert them into Contacts
if any(isinstan... | def forward(self, to_recipients, forward_comment=None) | Forward Message to recipients with an optional comment.
Args:
to_recipients: A list of :class:`Contacts <pyOutlook.core.contact.Contact>` to send the email to.
forward_comment: String comment to append to forwarded email.
Examples:
>>> john = Contact('john.doe@domai... | 3.490438 | 4.169673 | 0.837101 |
payload = '{ "Comment": "' + reply_comment + '"}'
endpoint = 'https://outlook.office.com/api/v2.0/me/messages/' + self.message_id + '/reply'
self._make_api_call('post', endpoint, data=payload) | def reply(self, reply_comment) | Reply to the Message.
Notes:
HTML can be inserted in the string and will be interpreted properly by Outlook.
Args:
reply_comment: String message to send with email. | 3.867764 | 3.632679 | 1.064714 |
payload = '{ "Comment": "' + reply_comment + '"}'
endpoint = 'https://outlook.office.com/api/v2.0/me/messages/{}/replyall'.format(self.message_id)
self._make_api_call('post', endpoint, data=payload) | def reply_all(self, reply_comment) | Replies to everyone on the email, including those on the CC line.
With great power, comes great responsibility.
Args:
reply_comment: The string comment to send to everyone on the email. | 4.096586 | 4.173836 | 0.981492 |
if isinstance(folder, Folder):
self.move_to(folder.id)
else:
self._move_to(folder) | def move_to(self, folder) | Moves the email to the folder specified by the folder parameter.
Args:
folder: A string containing the folder ID the message should be moved to, or a Folder instance | 3.413435 | 3.696325 | 0.923467 |
try:
file_bytes = base64.b64encode(file_bytes)
except TypeError:
file_bytes = base64.b64encode(bytes(file_bytes, 'utf-8'))
self._attachments.append(
Attachment(get_valid_filename(file_name), file_bytes.decode('utf-8'))
) | def attach(self, file_bytes, file_name) | Adds an attachment to the email. The filename is passed through Django's get_valid_filename which removes
invalid characters. From the documentation for that function:
>>> get_valid_filename("john's portrait in 2004.jpg")
'johns_portrait_in_2004.jpg'
Args:
file_bytes: The b... | 2.501987 | 2.404741 | 1.040439 |
tmp = 0.5*(1.0 - (img - img.min())/(img.max() - img.min()))
out = tmp*0.0
out[:,:,0] = tmp[:,:,1] + tmp[:,:,2]
out[:,:,1] = tmp[:,:,0] + tmp[:,:,2]
out[:,:,2] = tmp[:,:,0] + tmp[:,:,1]
return out | def tricolor_white_bg(self, img) | transforms image from RGB with (0,0,0)
showing black to RGB with 0,0,0 showing white
takes the Red intensity and sets
the new intensity to go
from (0, 0.5, 0.5) (for Red=0) to (0, 0, 0) (for Red=1)
and so on for the Green and Blue maps.
Thus the image will be transfor... | 2.668834 | 2.698494 | 0.989009 |
tmp = img*1.0
if whitebg:
tmp = (1.0 - (img - img.min())/(img.max() - img.min()))
out = tmp*0.0
out[:,:,0] = (tmp[:,:,1] + tmp[:,:,2])/2.0
out[:,:,1] = (tmp[:,:,0] + tmp[:,:,2])/2.0
out[:,:,2] = (tmp[:,:,0] + tmp[:,:,1])/2.0
return out | def rgb2cmy(self, img, whitebg=False) | transforms image from RGB to CMY | 2.296973 | 2.277514 | 1.008544 |
plugin_valid = False
for extension in self.extensions:
if filepath.endswith(".{}".format(extension)):
plugin_valid = True
break
return plugin_valid | def plugin_valid(self, filepath) | checks to see if plugin ends with one of the
approved extensions | 3.019088 | 2.539878 | 1.188675 |
return dict(EmailAddress=dict(Name=self.name, Address=self.email)) | def api_representation(self) | Returns the JSON formatting required by Outlook's API for contacts | 12.409827 | 7.632198 | 1.625983 |
# type: (OutlookAccount, bool) -> bool
endpoint = 'https://outlook.office.com/api/v2.0/me/InferenceClassification/Overrides'
if is_focused:
classification = 'Focused'
else:
classification = 'Other'
data = dict(ClassifyAs=classification, SenderEm... | def set_focused(self, account, is_focused) | Emails from this contact will either always be put in the Focused inbox, or always put in Other, based on
the value of is_focused.
Args:
account (OutlookAccount): The :class:`OutlookAccount <pyOutlook.core.main.OutlookAccount>`
the override should be set for
is_f... | 4.971608 | 4.76793 | 1.042718 |
"PIL image 2 wx bitmap"
if is_wxPhoenix:
wximg = wx.Image(*img.size)
else:
wximg = wx.EmptyImage(*img.size)
wximg.SetData(img.tobytes())
return wximg.ConvertToBitmap() | def image2wxbitmap(img) | PIL image 2 wx bitmap | 3.438842 | 2.980202 | 1.153896 |
for cmap_panel, img_panel in zip((self.cmap_panels[0], self.cmap_panels[1]),
(self.img1_panel, self.img2_panel)):
conf = img_panel.conf
img = img_panel.conf.data
if contrast_level is None:
contrast_level = 0
... | def set_contrast_levels(self, contrast_level=0) | enhance contrast levels, or use full data range
according to value of self.panel.conf.contrast_level | 3.016244 | 2.925622 | 1.030976 |
s = str(s).strip().replace(' ', '_')
return re.sub(r'(?u)[^-\w.]', '', s) | def get_valid_filename(s) | Shamelessly taken from Django.
https://github.com/django/django/blob/master/django/utils/text.py
Return the given string converted to a string that can be used for a clean
filename. Remove leading and trailing spaces; convert other spaces to
underscores; and remove anything that is not an alphanumeric,... | 1.83671 | 2.881815 | 0.637345 |
status_code = response.status_code
if 100 < status_code < 299:
return True
elif status_code == 401 or status_code == 403:
message = get_response_data(response)
raise AuthError('Access Token Error, Received ' + str(status_code) +
' from Outlook REST Endp... | def check_response(response) | Checks that a response is successful, raising the appropriate Exceptions otherwise. | 3.248148 | 3.139689 | 1.034544 |
plugins = self.plugins
if filter_function is not None:
plugins = filter_function(plugins)
return plugins | def get_plugins(self, filter_function=None) | Gets out the plugins from the internal state. Returns a list object.
If the optional filter_function is supplied, applies the filter
function to the arguments before returning them. Filters should
be callable and take a list argument of plugins. | 3.084954 | 2.63543 | 1.170569 |
return [x for x in self.plugins if isinstance(x, klasses)] | def _get_instance(self, klasses) | internal method that gets every instance of the klasses
out of the internal plugin state. | 7.325847 | 3.959198 | 1.850336 |
if isinstance(filter_function, (list, tuple)):
return self._get_instance(filter_function)
elif inspect.isclass(filter_function):
return self._get_instance(filter_function)
elif filter_function is None:
return self.plugins
else:
ret... | def get_instances(self, filter_function=IPlugin) | Gets instances out of the internal state using
the default filter supplied in filter_function.
By default, it is the class IPlugin.
Can optionally pass in a list or tuple of classes
in for `filter_function` which will accomplish
the same goal.
lastly, a callable can be ... | 2.368963 | 2.580772 | 0.917928 |
classes = util.return_list(classes)
for klass in classes:
IPlugin.register(klass) | def register_classes(self, classes) | Register classes as plugins that are not subclassed from
IPlugin.
`classes` may be a single object or an iterable. | 10.834189 | 7.424691 | 1.459211 |
plugins = util.return_list(plugins)
for instance in plugins:
if inspect.isclass(instance):
self._handle_class_instance(instance)
else:
self._handle_object_instance(instance) | def _instance_parser(self, plugins) | internal method to parse instances of plugins.
Determines if each class is a class instance or
object instance and calls the appropiate handler
method. | 3.884226 | 3.395562 | 1.143912 |
if (klass in self.blacklisted_plugins or not
self.instantiate_classes or
klass == IPlugin):
return
elif self.unique_instances and self._unique_class(klass):
self.plugins.append(klass())
elif not self.unique_instances:
s... | def _handle_class_instance(self, klass) | handles class instances. If a class is blacklisted, returns.
If uniuqe_instances is True and the class is unique, instantiates
the class and adds the new object to plugins.
If not unique_instances, creates and adds new instance to plugin
state | 6.457155 | 5.043412 | 1.280315 |
return not any(isinstance(obj, cls) for obj in self.plugins) | def _unique_class(self, cls) | internal method to check if any of the plugins are instances
of a given cls | 10.494775 | 4.651907 | 2.256015 |
plugins = util.return_list(plugins)
self.blacklisted_plugins.extend(plugins) | def add_blacklisted_plugins(self, plugins) | add blacklisted plugins.
`plugins` may be a single object or iterable. | 5.852413 | 7.029751 | 0.832521 |
plugins = util.return_list(plugins)
self.blacklisted_plugins = plugins | def set_blacklisted_plugins(self, plugins) | sets blacklisted plugins.
`plugins` may be a single object or iterable. | 7.137822 | 8.970783 | 0.795674 |
# removes filepaths from processed if they are not in sys.modules
self._update_loaded_modules()
filepaths = util.return_set(filepaths)
modules = []
for filepath in filepaths:
filepath = self._clean_filepath(filepath)
# check to see if already pro... | def load_modules(self, filepaths) | Loads the modules from their `filepaths`. A filepath may be
a directory filepath if there is an `__init__.py` file in the
directory.
If a filepath errors, the exception will be caught and logged
in the logger.
Returns a list of modules. | 4.757495 | 4.930768 | 0.964859 |
if modules is None:
modules = self.get_loaded_modules()
else:
modules = util.return_list(modules)
plugins = []
for module in modules:
module_plugins = [(item[1], item[0])
for item
in... | def collect_plugins(self, modules=None) | Collects all the plugins from `modules`.
If modules is None, collects the plugins from the loaded modules.
All plugins are passed through the module filters, if any are any,
and returned as a list. | 3.33623 | 3.123254 | 1.06819 |
module_plugin_filters = util.return_list(module_plugin_filters)
self.module_plugin_filters = module_plugin_filters | def set_module_plugin_filters(self, module_plugin_filters) | Sets the internal module filters to `module_plugin_filters`
`module_plugin_filters` may be a single object or an iterable.
Every module filters must be a callable and take in
a list of plugins and their associated names. | 3.238644 | 4.495036 | 0.720494 |
module_plugin_filters = util.return_list(module_plugin_filters)
self.module_plugin_filters.extend(module_plugin_filters) | def add_module_plugin_filters(self, module_plugin_filters) | Adds `module_plugin_filters` to the internal module filters.
May be a single object or an iterable.
Every module filters must be a callable and take in
a list of plugins and their associated names. | 3.04435 | 4.239102 | 0.718159 |
loaded_modules = []
for name in names:
loaded_modules.append(sys.modules[name])
return loaded_modules | def _get_modules(self, names) | An internal method that gets the `names` from sys.modules and returns
them as a list | 3.344487 | 3.039759 | 1.100247 |
modules = util.return_set(modules)
for module in modules:
if not isinstance(module, str):
module = module.__name__
self.loaded_modules.add(module) | def add_to_loaded_modules(self, modules) | Manually add in `modules` to be tracked by the module manager.
`modules` may be a single object or an iterable. | 3.437276 | 4.064674 | 0.845646 |
if self.module_plugin_filters:
# check to make sure the number of plugins isn't changing
original_length_plugins = len(plugins)
module_plugins = set()
for module_filter in self.module_plugin_filters:
module_plugins.update(module_filter(plu... | def _filter_modules(self, plugins, names) | Internal helper method to parse all of the plugins and names
through each of the module filters | 5.041337 | 4.466247 | 1.128763 |
if (os.path.isdir(filepath) and
os.path.isfile(os.path.join(filepath, '__init__.py'))):
filepath = os.path.join(filepath, '__init__.py')
if (not filepath.endswith('.py') and
os.path.isfile(filepath + '.py')):
filepath += '.py'
re... | def _clean_filepath(self, filepath) | processes the filepath by checking if it is a directory or not
and adding `.py` if not present. | 2.241551 | 2.0454 | 1.095898 |
processed = False
if filepath in self.processed_filepaths.values():
processed = True
return processed | def _processed_filepath(self, filepath) | checks to see if the filepath has already been processed | 6.48593 | 4.300809 | 1.508072 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.