Open context spreadsheet
180237
def tarbell_spreadsheet(command, args):
    
    with ensure_settings(command, args) as settings, ensure_project(command, args) as site:
        try:
            # First, try to get the Google Spreadsheet URL
            spreadsheet_url = _google_spreadsheet_url(site.project.SPREADSHEET_KEY)
        except AttributeError:
            # The project doesn't seem to be using a Google Spreadsheet.
            # Try the URL or path specified in the CONTEXT_SOURCE_FILE setting
            try:
                spreadsheet_url = _context_source_file_url(
                    site.project.CONTEXT_SOURCE_FILE)
                print(spreadsheet_url)
            except AttributeError:
                puts(colored.red("No Google spreadsheet or context source file "
                                 "has been configured.\n"))
                return

        # Use the webbrowser package to try to open the file whether it's a
        # remote URL on the web, or a local file.  On some platforms it will
        # successfully open local files in the default application.
        # This seems preferable to trying to do os detection and calling
        # the system-specific command for opening files in default
        # applications.
        # See
        # http://stackoverflow.com/questions/434597/open-document-with-default-application-in-python
        webbrowser.open(spreadsheet_url)
157781
def readExcel(usr_path=""):
    
    global cwd, files
    start = clock()
    files[".xls"] = []
    __read(usr_path, ".xls")
    end = clock()
    logger_benchmark.info(log_benchmark("readExcel", start, end))
    return cwd
871184
def create_or_open_table_at index
      t = self[index]
      t = self[index] = Workbook::Table.new if t == nil
      t.sheet = self
      t
    end
1221626
def get_context_from_xlsx(self):
        
        if re.search('^(http|https)://', self.project.CONTEXT_SOURCE_FILE):
            resp = requests.get(self.project.CONTEXT_SOURCE_FILE)
            content = resp.content
        else:
            try:
                with open(self.project.CONTEXT_SOURCE_FILE) as xlsxfile:
                    content = xlsxfile.read()
            except IOError:
                filepath = "%s/%s" % (
                    os.path.abspath(self.path),
                    self.project.CONTEXT_SOURCE_FILE)
                with open(filepath) as xlsxfile:
                    content = xlsxfile.read()

        data = process_xlsx(content)
        if 'values' in data:
            data = copy_global_values(data)

        return data
481749
def main():
  """"""
  parser = argparse.ArgumentParser(
      description='Reads in a .xls file and generates a units module for '
                  'OpenHTF.',
      prog='python units_from_xls.py')
  parser.add_argument('xlsfile', type=str,
                      help='the .xls file to parse')
  parser.add_argument(
      '--outfile',
      type=str,
      default=os.path.join(os.path.dirname(__file__), os.path.pardir,
                           'openhtf','util', 'units.py'),
      help='where to put the generated .py file.')
  args = parser.parse_args()

  if not os.path.exists(args.xlsfile):
    print('Unable to locate the file "%s".' % args.xlsfile)
    parser.print_help()
    sys.exit()

  unit_defs = unit_defs_from_sheet(
      xlrd.open_workbook(args.xlsfile).sheet_by_name(SHEET_NAME),
      COLUMN_NAMES)

  _, tmp_path = mkstemp()
  with open(tmp_path, 'w') as new_file:
    new_file.write(PRE)
    new_file.writelines(
        [line.encode('utf8', 'replace') for line in unit_defs])
    new_file.write(POST)
    new_file.flush()

  os.remove(args.outfile)
  shutil.move(tmp_path, args.outfile)
1127257
def export_context(cls, context):
		
		if context is None:
			return
		result = [(x.context_name(), x.context_value()) for x in context]
		result.reverse()
		return tuple(result)
672599
def view_context(self):
        
        url = self.get_selected_item().get('context')
        if url:
            self.selected_page = self.open_submission_page(url)
577326
def cli(env):
    """"""

    mask = ('openTicketCount, closedTicketCount, '
            'openBillingTicketCount, openOtherTicketCount, '
            'openSalesTicketCount, openSupportTicketCount, '
            'openAccountingTicketCount')
    account = env.client['Account'].getObject(mask=mask)
    table = formatting.Table(['Status', 'count'])

    nested = formatting.Table(['Type', 'count'])
    nested.add_row(['Accounting',
                    account['openAccountingTicketCount']])
    nested.add_row(['Billing', account['openBillingTicketCount']])
    nested.add_row(['Sales', account['openSalesTicketCount']])
    nested.add_row(['Support', account['openSupportTicketCount']])
    nested.add_row(['Other', account['openOtherTicketCount']])
    nested.add_row(['Total', account['openTicketCount']])
    table.add_row(['Open', nested])
    table.add_row(['Closed', account['closedTicketCount']])

    env.fout(table)
246810
function worksheetEntry(entry, fieldPrefix) {
    fieldPrefix = fieldPrefix || 'gsx$';

    var data = {
        '_id': getItemIdFromUrl(g(entry.id)),
        '_updated': g(entry.updated)
    };

    Object.keys(entry)
        .filter(function(key) {
            return ~key.indexOf(fieldPrefix) && g(entry[key], true);
        })
        .forEach(function(key) {
            var normalizedKey = key.substr(fieldPrefix.length);
            data[normalizedKey] = g(entry[key]);
        });

    return data;
}
238004
def get_worksheets_section(self):
        
        out = []
        bc = getToolByName(self.context, CATALOG_WORKSHEET_LISTING)
        query = {'portal_type': "Worksheet", }

        # Check if dashboard_cookie contains any values to query
        # elements by
        query = self._update_criteria_with_filters(query, 'worksheets')

        # Active Worksheets (all)
        total = self.search_count(query, bc.id)

        # Open worksheets
        name = _('Results pending')
        desc = _('Results pending')
        purl = 'worksheets?list_review_state=open'
        query['review_state'] = ['open', 'attachment_due']
        out.append(self._getStatistics(name, desc, purl, bc, query, total))

        # Worksheets to be verified
        name = _('To be verified')
        desc = _('To be verified')
        purl = 'worksheets?list_review_state=to_be_verified'
        query['review_state'] = ['to_be_verified', ]
        out.append(self._getStatistics(name, desc, purl, bc, query, total))

        # Worksheets verified
        name = _('Verified')
        desc = _('Verified')
        purl = 'worksheets?list_review_state=verified'
        query['review_state'] = ['verified', ]
        out.append(self._getStatistics(name, desc, purl, bc, query, total))

        # Chart with the evolution of WSs over a period, grouped by
        # periodicity
        outevo = self.fill_dates_evo(bc, query)
        out.append({'type':         'bar-chart-panel',
                    'name':         _('Evolution of Worksheets'),
                    'class':        'informative',
                    'description':  _('Evolution of Worksheets'),
                    'data':         json.dumps(outevo),
                    'datacolors':   json.dumps(self.get_colors_palette())})

        return {'id': 'worksheets',
                'title': _('Worksheets'),
                'panels': out}
645086
def sheets(self):
        """"""
        data = Dict()
        for src in [src for src in self.zipfile.namelist() if 'xl/worksheets/' in src]:
            name = os.path.splitext(os.path.basename(src))[0]
            xml = self.xml(src)
            data[name] = xml
        return data
873589
def edit(ctx, file_to_edit, previous_file):
    
    timesheet_collection = None
    autofill = not bool(file_to_edit) and previous_file == 0
    if not file_to_edit:
        file_to_edit = ctx.obj['settings'].get_entries_file_path(False)

    # If the file was not specified and if it's the current file, autofill it
    if autofill:
        try:
            timesheet_collection = get_timesheet_collection_for_context(
                ctx, file_to_edit
            )
        except ParseError:
            pass
        else:
            t = timesheet_collection.latest()

            if ctx.obj['settings']['auto_add'] != Settings.AUTO_ADD_OPTIONS['NO']:
                auto_fill_days = ctx.obj['settings']['auto_fill_days']
                if auto_fill_days:
                    t.prefill(auto_fill_days, limit=None)

                t.save()

    # Get the path to the file we should open in the editor
    timesheet_files = list(reversed(TimesheetCollection.get_files(file_to_edit, previous_file)))
    if previous_file >= len(timesheet_files):
        ctx.fail("Couldn't find the requested previous file for `%s`." % file_to_edit)

    expanded_file_to_edit = list(timesheet_files)[previous_file]

    editor = ctx.obj['settings']['editor']
    edit_kwargs = {
        'filename': expanded_file_to_edit,
        'extension': '.tks'
    }
    if editor:
        edit_kwargs['editor'] = editor

    click.edit(**edit_kwargs)

    try:
        # Show the status only for the given file if it was specified with the
        # --file option, or for the files specified in the settings otherwise
        timesheet_collection = get_timesheet_collection_for_context(
            ctx, file_to_edit
        )
    except ParseError as e:
        ctx.obj['view'].err(e)
    else:
        ctx.obj['view'].show_status(
            timesheet_collection.entries.filter(regroup=True, pushed=False)
        )
738890
def data_context(fn, mode="r"):
    
    with open(data_context_name(fn), mode) as f:
        return f.read()
547453
function doExport() {
		/*
			If opts is array of arrays then this is a
			multisheet workboook, else it is a singlesheet
		*/
		if (typeof opts == 'object' && Array.isArray(opts)) {
			if (data && data.length > 0) {
				data.forEach(function(dat, idx) {
					prepareSheet(opts[idx], dat, undefined, idx + 1);
				});
			}
		} else {
			prepareSheet(opts, data, columns, 1);
		}

		saveWorkbook(cb);
	}
521214
def get_context_data(self, **kwargs):
        
        context = super(BaseEntrySearch, self).get_context_data(**kwargs)
        context.update({'error': self.error, 'pattern': self.pattern})
        return context
48452
def spreadsheet(service, id):
    """"""
    request = service.spreadsheets().get(spreadsheetId=id)
    try:
        response = request.execute()
    except apiclient.errors.HttpError as e:
        if e.resp.status == 404:
            raise KeyError(id)
        else:  # pragma: no cover
            raise
    return response
1084026
def context_menu_requested(self, event):
        """"""
        if self.fig:
            pos = QPoint(event.x(), event.y())
            context_menu = QMenu(self)
            context_menu.addAction(ima.icon('editcopy'), "Copy Image",
                                   self.copy_figure,
                                   QKeySequence(
                                       get_shortcut('plots', 'copy')))
            context_menu.popup(self.mapToGlobal(pos))