<commit_before>package main

import (
	"encoding/json"

	"log"
	"os"
	"path/filepath"

	"github.com/jessevdk/go-flags"
	"sourcegraph.com/sourcegraph/srclib-python/python"
	"sourcegraph.com/sourcegraph/srclib/dep"
	"sourcegraph.com/sourcegraph/srclib/unit"
)

var (
	parser = flags.NewNamedParser("srclib-python", flags.Default)
	cwd    string
)

func init() {
	parser.LongDescription = "srclib-python performs Python package, dependency, and source analysis."

	var err error
	cwd, err = os.Getwd()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	log.SetFlags(0)
	if _, err := parser.Parse(); err != nil {
		os.Exit(1)
	}
}

func init() {
	_, err := parser.AddCommand("scan",
		"scan for Python packages",
		"Scan the directory tree rooted at the current directory for Python packages.",
		&scanCmd,
	)
	if err != nil {
		log.Fatal(err)
	}
}

type ScanCmd struct {
	Repo   string `long:"repo" description:"repository URI" value-name:"URI"`
	Subdir string `long:"subdir" description:"subdirectory in repository" value-name:"DIR"`
}

var scanCmd ScanCmd

func (c *ScanCmd) Execute(args []string) error {
	units, err := python.Scan(".", c.Repo, c.Subdir)
	if err != nil {
		return err
	}
<commit_msg>accept --config<commit_after>package main

import (
	"encoding/json"

	"log"
	"os"
	"path/filepath"

	"github.com/jessevdk/go-flags"
	"sourcegraph.com/sourcegraph/srclib-python/python"
	"sourcegraph.com/sourcegraph/srclib/dep"
	"sourcegraph.com/sourcegraph/srclib/unit"
)

var (
	parser = flags.NewNamedParser("srclib-python", flags.Default)
	cwd    string
)

func init() {
	parser.LongDescription = "srclib-python performs Python package, dependency, and source analysis."

	var err error
	cwd, err = os.Getwd()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	log.SetFlags(0)
	if _, err := parser.Parse(); err != nil {
		os.Exit(1)
	}
}

func init() {
	_, err := parser.AddCommand("scan",
		"scan for Python packages",
		"Scan the directory tree rooted at the current directory for Python packages.",
		&scanCmd,
	)
	if err != nil {
		log.Fatal(err)
	}
}

type ScanCmd struct {
	Repo   string   `long:"repo" description:"repository URI" value-name:"URI"`
	Subdir string   `long:"subdir" description:"subdirectory in repository" value-name:"DIR"`
	Config []string `long:"config" description:"config property from Srcfile" value-name:"KEY=VALUE"`
}

var scanCmd ScanCmd

func (c *ScanCmd) Execute(args []string) error {
	units, err := python.Scan(".", c.Repo, c.Subdir)
	if err != nil {
		return err
	}

{'fraction_non_alphanumeric': 0.14683645045762037, 'fraction_numerical': 0.0015917230401910067, 'mean_word_length': 4.109756097560975, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2284086', 'n_tokens_mistral': 932, 'n_tokens_neox': 905, 'n_words': 223}