How to use the nitpick.config.db_path function in nitpick

To help you get started, we’ve selected a few nitpick examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github travisb-ca / nitpick / nitpick.py View on Github external
def cmd_init(args):
	backend = BACKENDS[args.vcs]
	config.db_path = args.dir + '/'

	def_config = {
			'vcs'          : args.vcs,
			'project_name' : 'Nitpick Project',
			'schedule'     : False,
		}

	for key in default_config.keys():
		def_config[key] = ' '.join(default_config[key])

	backend.mkdir(args.dir + '/config')

	config_filename = args.dir + '/config/config'
	format_file(config_filename, def_config)
	backend.add_changes(config_filename)
github travisb-ca / nitpick / nitpick.py View on Github external
self.repo_paths = { self.uuid : [config.db_path] }

		try:
			cache_file = gzip.open(config.db_path + 'issue_cache', 'r')
			self.db = cPickle.load(cache_file)
			cache_file.close()
		except:
			# Something is wrong with the cache, so start again
			self.db = {'format' : ISSUE_CACHE_FORMAT}

		if 'format' not in self.db.keys() or self.db['format'] != ISSUE_CACHE_FORMAT:
			self.db = {'format' : ISSUE_CACHE_FORMAT}

		checked_issues = {}
		seen_uuids = []
		if os.path.exists(config.db_path + 'foreign') and os.path.isdir(config.db_path + 'foreign'):
			self.foreign_repos = True

			for foreign_repo in os.listdir(config.db_path + 'foreign'):
				if foreign_repo[0] == '.':
					# Skip VCS dotfiles
					continue

				foreign_path = config.db_path + 'foreign/' + foreign_repo + '/'

				try:
					uuid_file = open(foreign_path + 'uuid', 'r')
					foreign_uuid = uuid_file.read()
					uuid_file.close()
				except:
					# If loading the foreign project fails warn and carry on
					print 'WARNING: Unableto load foreign project "%s"' % foreign_repo
github travisb-ca / nitpick / nitpick.py View on Github external
self.update_cache_from_repo(foreign_path, foreign_uuid, foreign_repo))
				seen_uuids.append(foreign_uuid)

				_load_config(foreign_path)

				self.repo_list[foreign_repo] = (foreign_uuid, foreign_path)
				if foreign_uuid in self.repo_paths:
					self.repo_paths[foreign_uuid].append(foreign_path)
				else:
					self.repo_paths[foreign_uuid] = [foreign_path]

		if self.uuid not in checked_issues.keys():
			checked_issues[self.uuid] = []

		checked_issues[self.uuid].extend(
				self.update_cache_from_repo(config.db_path, self.uuid, 'Local'))
		seen_uuids.append(self.uuid)
		
		# Delete any foreign repositories which have been removed
		for repo in self.db.keys():
			if repo == 'format':
				continue

			if repo not in seen_uuids:
				del self.db[repo]

		# Delete any issues which no longer exist in repositories we have seen
		for repo in checked_issues.keys():
			for issue in self.db[repo].keys():
				if issue not in checked_issues[repo]:
					del self.db[repo][issue]
					pass
github travisb-ca / nitpick / nitpick.py View on Github external
def load_config():
	# First we need to seek up until we find the database. It should be at the root of the project
	pwd = os.path.abspath('.')
	while pwd != '/':
		if os.path.exists(pwd + '/.nitpick') and os.path.isdir(pwd + '/.nitpick'):
			config.db_path = pwd + '/.nitpick/'
			break
		pwd = os.path.dirname(pwd)
	if config.db_path == '':
		return False

	for key in ['components', 'fix_by', 'priority', 'severity', 'state', 'resolution', 'type']:
		config.issues[key] = []
	
	_load_config(config.db_path)

	# Try to figure out the username to use.
	if 'NITPICK_USERNAME' in os.environ:
		config.username = os.environ['NITPICK_USERNAME']
	else:
		# Try to match the current user against the username list
		if 'USER' not in os.environ:
github travisb-ca / nitpick / nitpick.py View on Github external
def load_config():
	# First we need to seek up until we find the database. It should be at the root of the project
	pwd = os.path.abspath('.')
	while pwd != '/':
		if os.path.exists(pwd + '/.nitpick') and os.path.isdir(pwd + '/.nitpick'):
			config.db_path = pwd + '/.nitpick/'
			break
		pwd = os.path.dirname(pwd)
	if config.db_path == '':
		return False

	for key in ['components', 'fix_by', 'priority', 'severity', 'state', 'resolution', 'type']:
		config.issues[key] = []
	
	_load_config(config.db_path)

	# Try to figure out the username to use.
	if 'NITPICK_USERNAME' in os.environ:
		config.username = os.environ['NITPICK_USERNAME']
	else:
		# Try to match the current user against the username list
		if 'USER' not in os.environ:
			print "Warning: Unable to determine username. Please set NITPICK_USERNAME"
		else:
			user = os.environ['USER']
			for row in config.users:
				if user in row:
					if config.username != '':
						print "Warning: Unable to determine username. Please set NITPICK_USERNAME"
						break
					else:
github travisb-ca / nitpick / nitpick.py View on Github external
def cmd_export(args):
	if config.db_path == '':
		return False

	load_db()

	hash = db.disambiguate_hash(args.issue)
	if hash == None:
		print "No such issue"
		return False
	elif hash == '':
		print "Ambiguous issue ID. Please use a longer string"
		return False

	print format_issue_for_export(hash)

	return True