-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ability to use external contact management software for assigning names
Currently names for addresses are assigned based on how common they are in the users email, but this might not be always preferable. Add the ability to override names calculated by maildir-rank-addr using an external address lookup command.
- Loading branch information
1 parent
6bd8741
commit 022d14a
Showing
8 changed files
with
132 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
package main | ||
|
||
import () | ||
|
||
func main() { | ||
config := loadConfig() | ||
data := walkMaildir(config.maildir, config.addresses, config.customFilters) | ||
addressbook := parseAddressbook(config.addressbookLookupCommand) | ||
data := walkMaildir(config.maildir, config.addresses, config.customFilters, addressbook) | ||
classeddata := calculateRanks(data) | ||
saveData(classeddata, config.outputpath, config.template) | ||
saveData(classeddata, config.outputpath, config.template, addressbook, config.addressbookAddUnmatched) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"log" | ||
"os/exec" | ||
"strings" | ||
) | ||
|
||
func parseAddressbook( | ||
cmd *exec.Cmd, | ||
) map[string]string { | ||
if cmd == nil { | ||
return nil | ||
} | ||
addressbook := make(map[string]string) | ||
out, err := cmd.StdoutPipe() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
if err := cmd.Start(); err != nil { | ||
log.Fatal(err) | ||
} | ||
scanner := bufio.NewScanner(out) | ||
for scanner.Scan() { | ||
slice := strings.Split(scanner.Text(), "\t") | ||
if len(slice) < 2 { | ||
fmt.Println("Couldn't parse ", scanner.Text()) | ||
} else { | ||
addressbook[strings.ToLower(slice[0])] = slice[1] | ||
} | ||
} | ||
if err := cmd.Wait(); err != nil { | ||
log.Fatal(err) | ||
} | ||
return addressbook | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters