Skip to content

Commit

Permalink
fix: minor tweaks to support S3 in Python (#632)
Browse files Browse the repository at this point in the history
* fix: minor tweaks to support S3 in Python
  • Loading branch information
justplaz authored Oct 11, 2024
1 parent 0ac4a65 commit 7982ad4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import software.amazon.smithy.model.shapes.TimestampShape;
import software.amazon.smithy.model.shapes.UnionShape;
import software.amazon.smithy.model.traits.EnumTrait;
import software.amazon.smithy.model.traits.StreamingTrait;
import software.amazon.smithy.python.codegen.GenerationContext;
import software.amazon.smithy.python.codegen.PythonWriter;

Expand Down Expand Up @@ -74,6 +75,10 @@ protected String getDefault(Shape shape) {

@Override
public String blobShape(BlobShape shape) {
// if it's a streaming blob, read it first
if (shape.hasTrait(StreamingTrait.class)) {
return "Seq(" + dataSource + ".read())";
}
writer.addStdlibImport("_dafny", "Seq");
return "Seq(" + dataSource + ")";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,15 @@ public static String getDafnyTypeForStringShapeWithEnumTrait(
);
}

final String replacedEnumValue = enumValue
.replace("_", "__")
.replace("-", "__")
.replace(":", "__");

return (
mangleDafnyType(stringShape.getId().getName()) +
"_" +
mangleDafnyType(enumValue.replace("_", "__"))
mangleDafnyType(replacedEnumValue)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ModelUtils {
// The spec recommends a similar stricter definition for consistency (uppercase instead of title-case):
// https://smithy.io/1.0/spec/core/constraint-traits.html?highlight=enum#enum-trait
private static final Pattern ENUM_NAME_PATTERN = Pattern.compile(
"^[A-Z]+[A-Za-z_0-9]*$"
"^[A-Za-z_0-9]*$"
);

/**
Expand Down

0 comments on commit 7982ad4

Please sign in to comment.